In: Computer Science
#Write a function called wish_list. wish_list should have
#four parameters, in this order:
#
# - a list of strings, representing a list of items on a
# wish list
# - a string, representing a particular item
# - a float, representing the cost of this item
# - a float, representing your budget
#
#If the item is on the list and you can afford it (cost is
#less than or equal to budget), return the string,
#"You should buy a [item name]!", replacing [item name]
#with the string.
#
#If the item is on the list but you can't afford it,
#return the string, "You should save up for a [item name]!",
#replacing [item name] with the string.
#
#If the item is not on the list, you should return the
#string "You probably don't want to buy a [item name].",
#replacing [item name] with the string.
#
#HINT: You do not need a loop to solve this. You can use
#one, but you don't need one.
# Write a function called wish_list. wish_list should have # four parameters, in this order: # # - a list of strings, representing a list of items on a # wish list # - a string, representing a particular item # - a float, representing the cost of this item # - a float, representing your budget # # If the item is on the list and you can afford it (cost is # less than or equal to budget), return the string, # "You should buy a [item name]!", replacing [item name] # with the string. # # If the item is on the list but you can't afford it, # return the string, "You should save up for a [item name]!", # replacing [item name] with the string. # # If the item is not on the list, you should return the # string "You probably don't want to buy a [item name].", # replacing [item name] with the string. # # HINT: You do not need a loop to solve this. You can use # one, but you don't need one. def wish_list(items, item, cost, budget): if item in items: if cost <= budget: return "You should buy a {}!".format(item) else: return "You should save up for a {}!".format(item) else: return "You probably don't want to buy a {}.".format(item)