Skip to content

Instantly share code, notes, and snippets.

@MrDMurray
Created September 26, 2016 18:56
Show Gist options
  • Save MrDMurray/e19dc7e4f4f36378f5168997708a1666 to your computer and use it in GitHub Desktop.
Save MrDMurray/e19dc7e4f4f36378f5168997708a1666 to your computer and use it in GitHub Desktop.
STJLOL-DMU-Lists: The pokeshop
bag = ['pokeball',"pokedex"] #makes a list with two items called bag
print("Welcome to the pokeshop!")
print("Let's see what's in your bag")
print (bag) #prints out what items are in the bag starting off
while True: #loops this part till a purchase is made
print("What would you like to buy? We have the following in our shop")
buy_choice=input("ultraball, raspberry ") #the user makes a choice
if buy_choice== "ultraball":
bag.append("ultraball") #adds a new list item "ultraball"
break #breaks out of the loop, done shopping.
elif buy_choice== "raspberry":
bag.append("raspberry") #adds a new list item "raspberry"
break #breaks out of the loop, done shopping.
else:
print("We don't sell eh... "+ buy_choice + ", sorry!")
print("Great choice. Thanks for shopping with us!. Let's see what's in your bag now..")
print (bag) #prints the updated contents of the bag
"""
OUTPUT LOOKS LIKE THIS:
>>>Welcome to the pokeshop!
Let's see what's in your bag
['pokeball', 'pokedex']
What would you like to buy? We have the following in our shop
ultraball, raspberry
>>>user type in the word.. "ultraball"
Great choice. Thanks for shopping with us!. Let's see what's in your bag now..
['pokeball', 'pokedex', 'ultraball']
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment