mardi 13 juillet 2021

how to get input from user and put them into a list then choose a random one from them without having to ask multiple times (python)

It's my 4th day learning programming so I'm very new to it. and I'm trying to get the user's info(hobbies) in one question and save them into a list then give back the user one of the hobbies they chose. this what I've came up with

import random

fav_hobbies = []
hobbies = input("what are your favourite hobbies?(cooking, writing,ect) ").lower()
fav_hobbies.append(hobbies)

situation = input("so are you bored now?(answer with yes or no): ").lower()
if situation == "yes":
     print("you should try " + random.choice(fav_hobbies))

elif boredom_situation == "no":
     print("awesome! have a nice day!")

the problem is that instead of choosing a word between the words that user's chose it just prints all of the things they said. how do I fix this?




Aucun commentaire:

Enregistrer un commentaire