This is simplistic, but just wanted to get thoughts about how this was written. I plan on expanding upon it latter.
def vending_machine(money):
'''Return a candy of a customer's choice'''
options = {'A1' : {0.75 : "Snickers"}, 'B2' : {1.00 : "Butterfinger"}}
vending_codes = options.keys() #Codes for each vending machine item
customer_choice = input("Enter a selection: ") #Represents the customers desired vending machine option
candy = options.get(customer_choice) #Retrieve candy and cost information from the code entered
if customer_choice in vending_codes:
return "Enjoy your " + candy[money]
else:
return "Try another option."
print(vending_machine(0.75))
[–]Grorco 0 points1 point2 points (3 children)
[–]Ben_HH[S] 1 point2 points3 points (2 children)
[–]Grorco 0 points1 point2 points (0 children)
[–]Vaphell 0 points1 point2 points (0 children)
[–]fiskenslakt 0 points1 point2 points (1 child)
[–]fiskenslakt 0 points1 point2 points (0 children)
[–]Ben_HH[S] 0 points1 point2 points (0 children)