I'm trying to get my script to choose between three options of conversation, labeled petconvo1, petconvo2, or petconvo3. The program asks what pet the user has and then picks a random thing to say about them. Based on what tidbit the script picks, I want to continue the conversation there. My problem is that it just stops and doesn't keep going with the conversation. What's the best way to do this?
My code is below.
#imports the random module
import random
#Asks what pet the user has
pet = input("What kind of pet do you have? ")
#Sets the input to lowercase
petlower = pet.lower()
#Sets tidbits of conversation about the pet
petconvo1 = ("Oh, I've heard that " + petlower + " is a good companion to have.")
petconvo2 = ("Oh, really? I had " + petlower + " when I was growing up.")
petconvo3 = ("Does it cost a lot to keep " + petlower + " fed?")
#Turns the tidbits into a list
petconvolist = [petconvo1, petconvo2, petconvo3]
#Compliments pet
print(random.choice(petconvolist))
#Continues the conversation
if petconvolist == petconvo1:
time.sleep(1)
print("Wouldn't you agree?")
else:
if petconvolist == petconvo2:
time.sleep(1)
print("I think it's important for children to grow up with pets.")
else:
if petconvolist == petconvo3:
time.sleep(1)
foodbudget=input("Does it cost a lot to feed " + petlower + "?")
time.sleep(.5)
else: pass
The script stops after this bit:
print(random.choice(petconvolist))
Thanks in advance!
Aucun commentaire:
Enregistrer un commentaire