Skip to content

Instantly share code, notes, and snippets.

@kat-perreira
Created January 27, 2021 06:06
Show Gist options
  • Save kat-perreira/55a6f1062e62ca4c1dbbc058f9314562 to your computer and use it in GitHub Desktop.
Save kat-perreira/55a6f1062e62ca4c1dbbc058f9314562 to your computer and use it in GitHub Desktop.
While loop practice
# while something is true, do the thing
# print all numbers that are less than 5
def less_than_5():
thing_to_return = []
i = 0 # set something to less than 5 ()
while i < 5:
thing_to_return.append(i)
i += 1
print(thing_to_return)
return thing_to_return
if less_than_5() == [0,1,2,3,4]:
print("passed")
else:
print("try again!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment