Please help me figure out how to do this.
ArtemPionov (8)


I'm currently programming a text-based game on python
and my struggle is:
I'm coding a game and I code different parts of the game use def and I want to ask for a user to input their character's name and then ask a question if they are sure and based on that do an if, else statement.

The code:

yes = ["Y", "y", "Yes", "yes"]
no = ["N", "n", "No", "no"]

def main_character():
  main_character = print(input("What's your character's name?"))
main_character = input(">>> "("Are you sure?"))
if main_character in yes:
else main_character in no:

I want the code to set in the def main_character and I want the code to a user for the name are ask a question if the user is sure with the name and then do an if statement that gets input from the question and I have assigned variable "yes" and and "no" and if input from the question falls in the yes variable then continue to intro() which is beginning of the game and if the answer from the question falls into no variable then go back to the naming of the character.
Please help me! Thank you!

You are viewing a single comment. View All
a5rocks (821)

Use elif instead of else. else is a blanket statement, it doesn't check a condition, while elif does.