I tried to make it only ask "do you want to continue" 3 times but it doesn't seem to work, it just kept on running. How do I fix this? It is a chat-response program which the computer askes one question and the user response.
def choice():
        prompts = [feeling, homesick, miss]
        random.choice(prompts)()
for item in range(3):
    choice()
This is the code I have written for it. but it does not work.
 import random
    
    name = input("What is your name? ")
    
    def restart():
        restart=input('do you want to continue? ')
        if restart=='yes':
            choice()
        else:
            print("ok, see you later!")
            exit()
            
    def feeling():
        response = input("How are you feeling right now {name}?".format(name=name))
        if response == "tired":
            tired = ['I wish I can make you feel better.','I hope school is not making you feel stressed.','You deserve the right to relax.']
            print(random.choice(tired))
            restart()
        else:
            print("Sorry, I don't understand what you mean by "+response+".")
            exit()
    
    def homesick():
        response = input("Do you miss your home? ")
        if response == "yes":
            yes=["Don't worry, you will be home soon......",'I am protecting your family and loved ones, trust me on this.',"Your kingdoms has been waiting for a long time, they'd forgiven your mistakes"]
            print(random.choice(yes))
            restart()
        else:
            print("Sorry, I don't understand what you mean by "+response+".")
            exit()
    
    def miss():
         response = input("Who do you miss?")
         if response == "my mom":
             print("Mom will be in town soon")
             restart()
         else:
            print("Sorry, I don't understand what you mean by "+response+".")
            exit()
    
    def choice():
        prompts = [feeling, homesick, miss]
        random.choice(prompts)()
    
    for item in range(3):
        choice()
 
    