Skip to content

Instantly share code, notes, and snippets.

@monipip3
Created January 9, 2018 02:25
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 monipip3/a9e54e8ac69efb480eb6eeef1c4b0f57 to your computer and use it in GitHub Desktop.
Save monipip3/a9e54e8ac69efb480eb6eeef1c4b0f57 to your computer and use it in GitHub Desktop.
PBJ sandwich using a while loop
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