Toggle navigation
English
Chinese
Python Sandbox
Please refer to
this tutorial
to find more details on the following codes.
# # For loop runs the same code block many times. # The following three code blocks produce the same output, but the last # one needs least typing. # # option 1 print("5 times 1 is", 5*1) print("5 times 2 is", 5*2) print("5 times 3 is", 5*3) print("5 times 4 is", 5*4) print("5 times 5 is", 5*5) print("5 times 6 is", 5*6) print("5 times 7 is", 5*7) print("5 times 8 is", 5*8) print("5 times 9 is", 5*9) print("5 times 10 is", 5*10) # option 2 for i in [1,2,3,4,5,6,7,8,9,10]: print("5 times", i, "is", 5*i) print("completed for loop") # option 3 for i in range(1,11): print("5 times", i, "is", 5*i)` print("completed for loop")
Run
List