Skip to content

Instantly share code, notes, and snippets.

@DaraDDB1
Last active October 4, 2016 09:42
Show Gist options
  • Save DaraDDB1/743b47fd8c22b8524fbd4402a1e7033b to your computer and use it in GitHub Desktop.
Save DaraDDB1/743b47fd8c22b8524fbd4402a1e7033b to your computer and use it in GitHub Desktop.
STJLOL-DC-forloops.py
#this code is the for loop
#easy task
bag = ["iPad", "pencil case", "books", "lunch"] #this is whats in the bag
for item in bag:
if item == "iPad":
print("Hey, look! I have your iPad!") #when ipad comes through, it will print this
else:
print("This isn't an iPad!") #if it isnt ipad, it will print this
for item in bag:
if item == "books":
print("You have lots of books!") #same thing as above but with books instead of ipad
else:
print("I wonder what this is, because they aren't books") #if the answer isnt ipad it will print this statement
#the output will say "hey look i have your ipad"then say "this isnt an ipad" x3
#^^^same with books ^^^
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment