Skip to content

Instantly share code, notes, and snippets.

@georgesb
Created October 22, 2024 07:00
Show Gist options
  • Save georgesb/c9f9bf4f077648e8920fd6115777c372 to your computer and use it in GitHub Desktop.
Save georgesb/c9f9bf4f077648e8920fd6115777c372 to your computer and use it in GitHub Desktop.
Python loops - While and For
# while loop example
evens = 2
while evens <= 10:
print evens
evens = evens + 2
print
# for loop example, increment n by 1
for n in range(1, 11):
print n
print
# for loop example, increment n by 2
for n in range(2, 12,2):
print(n)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment