I'm still learning...but I like using dictionaries for instances like this. Maybe something like:
# Dictionary of {selections: values}
plants={1:"Tulip",2:"Rose bush",3:"Pineapple",4:"Banana"}# Print options using loop and get selection from user
print("Which seed do you want to buy?")forentryinplants:print(f'{entry}: {plants[entry]}')selection=int(input("Selection: "))# Print value from dictionary or message if not found
print(plants.get(selection,"Invalid option."))
There are probably better ways, but this works for me. :)
@vebss
good question!!
I'm still learning...but I like using dictionaries for instances like this. Maybe something like:
There are probably better ways, but this works for me. :)
@Brandon thanks, for this tip! :))