1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| list_shop = {'phone' : 5, 'screen' : 1, 'tv' : 50, 'cow' : 49, 'pen':9}
def check_shop(list_shop,object):
try:
list_shop[object]
except KeyError:
print("Error, the object {} is not allowed, please write only things into this: {}".format(object,list_shop.keys()))
print(check_shop(list_shop,input("Enter your object: \n")))
return object
budget = input("Enter your budget:\n")
object_1 = check_shop(list_shop, input("Enter your object: \n"))
object_2 = check_shop(list_shop, input("Enter your 2nd object: \n"))
total = int(budget) - ((list_shop[object_1] - list_shop[object_2]))
print("After your 2 expanses ({} and {}), you have now ${} remaining".format(object_1,object_2,total)) |
Partager