Created
January 9, 2018 02:25
-
-
Save monipip3/a9e54e8ac69efb480eb6eeef1c4b0f57 to your computer and use it in GitHub Desktop.
PBJ sandwich using a while loop
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
bread = 12 | |
peanut_butter = 10 | |
jelly = 14 | |
i = min(bread/2, peanut_butter, jelly) | |
while i > 0: | |
print "I can make {0} sandwiches".format(i) | |
bread = bread - 2 | |
jelly = jelly - 1 | |
peanut_butter = peanut_butter - 1 | |
i = i -1 | |
print "And I have enough bread for {0} more sandwiches, enough peanut butter for {1} more, and enough jelly for {2} more.".format(bread/2, peanut_butter, jelly) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment