Jun-02-2020, 06:34 PM
I am coding a text based game and I need to find out the name of the players character, and confirm that it is spelled correctly.
The interaction should be:
1 2 3 4 5 6 7 8 9 10 11 12 |
def name_ask(): print ( 'Hello, what is your name, hero?\n' ), player_name = input ( '> ' ) print ( 'Hello ' + (player_name) + '. Is your name correct?' ) asknamecorrect = input ( '> ' ) if asknamecorrect = = ( 'yes' , 'Yes' ): print ( 'Good.' ) elif asknamecorrect = = ( 'no' , 'No' ): name_ask() else : print ( 'Please answer with a yes or a no.' ) name_ask() |
Output:Hello, what is your name hero?
> name
Hello name. Is your name correct?
>yes
Good.
What I get:Output:Hello, what is your name hero?
> name
Hello name. Is your name correct?
> yes
Please answer with a yes or a no.
Hello, what is your name, hero?
>
It turns into an endless loop. How do I fix this? Thank you.