Last active
November 6, 2017 13:58
-
-
Save j-nordell/7c6ae4aed673760e3defb61445d79cf8 to your computer and use it in GitHub Desktop.
Review break statements (for loop example)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cookie_jar = ["chocolate chip", "oatmeal raisin", "ginger", | |
"peanut butter", "sugar", "Oreo"] # I have these cookies in my cooke jar | |
for cookie in cookie_jar: | |
# (This may look complex, but don't worry about it right now. | |
# It just checks to see if we've tried half the cookies yet) | |
if cookie_jar.index(cookie) >= len(cookie_jar) / 2: # If we've already tasted half the cookies, | |
print("I've had enough cookies for today") | |
break # Call it quits for the day | |
print(f"The {cookie} cookie tastes delicious!") # Otherwise, take a bite! | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment