Python Loops

Loops allow you to execute a block of code multiple times. There are 2 types of loops in Python:

  • For Loops
  • While Loops

Writing a For Loop based on a range: The range function generates a sequence of numbers starting with 0.

Writing a For Loop based on a subset of a range: Use the range function to generate a loop starting at position 5 and ending at position 9

Writing a For Loop using step counts: Use the range function to generate a loop with 10 positions and output only every 2 positions.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

No responses yet

Write a response