Skip to content

Instantly share code, notes, and snippets.

@Kcrong
Created March 22, 2018 11:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kcrong/565e7165b62cb45aea478c82902d7261 to your computer and use it in GitHub Desktop.
Save Kcrong/565e7165b62cb45aea478c82902d7261 to your computer and use it in GitHub Desktop.
# with for loop
# range() --> starts from 0
def with_for_loop():
for i in range(10):
print('Hit %d times' % (i+1))
print('The tree fell down!!')
def with_while_loop():
hit = 0
while hit < 10:
print('Hit %d times' % (i+1))
hit = hit + 1
print('The tree fell down!!')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment