Python for Everybody: Learn Python from Scratch
About Lesson
  • Loops: Master for and while loops for iteration.

Loops allow us to repeat a block of code multiple times. Two common types are:

  1.  for Loop:

    for i in range(5):
    print(f”Count: {i}”)

    //This loop will print numbers from 0 to 4.

  2. while Loop:

               num = 1

                while num <= 10:

                     print(num)
                   num += 1

// This loop will print numbers from 1 to 10.

Join the conversation