-1

I have seen this post, but I'm not sure it applies.

I am looking for an easy - minimal calls for packages or special functions - to code in Python what in Maple would be:

x:=0:
for m1 from 0 to 9 do
  for m2 from 0 to m1-1 do
    for m3 from 0 to m2-1 do
      for m4 from 0 to m3-1 do
        for m5 from 0 to m4-1 do
          x:=x+1
        od
      od
    od
  od
od:
x;
Antoni Parellada
  • 4,253
  • 6
  • 49
  • 114

1 Answers1

2

Here is your answer:

x = 0
for m1 in range(10):
  for m2 in range(m1):
    for m3 in range(m2):
      for m4 in range(m3):
        for m5 in range(m4):
          x = x + 1

As you can see, range() turns a given number n into a list comprised by the numbers [0, 1, 2, ..., n-1].

David
  • 567
  • 4
  • 16