Please help with code below! - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Please help with code below! (/thread-7686.html) |
Please help with code below! - PyCoder - Jan-21-2018 from time import sleep print("Welcome to my first game") char_name = "" def choosingname(name): name = input("What is your charactar's name?: ") print(name) YorN() def YorN(): correctornot = input("Enter Y for yes if name is correct, enter N for no if name is not correct: ") if correctornot == "Y": print("You have your character's name!") elif correctornot == "N": print("Let's input the name again") choosingname() else: print("Invalid, neither Y or N was entered.") YorN() choosingname(char_name) print("CityBuilder: The Game. Is now running.") sleep(1) print("Hello %s, what's your city going to be called?" % char_name)(Out of the code now: The code on the last line never prints the user's name why is that?) Please help RE: Please help with code below! - PyCoder - Jan-21-2018 Yeah I know, that's all the code in the right format. RE: Please help with code below! - Mekire - Jan-21-2018 You should not be looping using recursion for a problem like this. It isn't what recursion is for. Rewrite your program to loop with a while loop and I think you will see the issue.
RE: Please help with code below! - PyCoder - Jan-23-2018 (Jan-21-2018, 06:14 AM)Mekire Wrote: You should not be looping using recursion for a problem like this. It isn't what recursion is for. Rewrite your program to loop with a Thanks, I have tried a while loop but I shall try again (I'm new to python :))
|