1. for i in range()
When you know how many times to repeat, use for with range():
range(5)gives 0, 1, 2, 3, 4 (five numbers, starting at 0)range(1, 11)gives 1 to 10 (the end number is not included)range(2, 11, 2)gives 2, 4, 6, 8, 10 (step of 2)
for i in range(1, 4): runs the block three times, with i being 1, then 2, then 3. No counter to update by hand, so no infinite loop.
for i in range(1, 4):
print("Round", i)
for n in range(2, 11, 2):
print(n)
Challenge: Pahada (times table)
Read a number n and print its times table from 1 to 10 with a for loop, in exactly this form: 7 x 1 = 7, 7 x 2 = 14, … 7 x 10 = 70.