#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    2
    Rep Power
    0

    Function parameter not defined


    Hi, I am very new to python, and have started making a Text based game, but there is a problem.
    -----------------------------------------------------------
    # Welcomes player and select name
    name = input('''Welcome to Text RPG.
    A world of magic and adventure awaits!
    What is your name?
    ''')
    print('Hello ' + str(name) + '!')

    # Function for choosing player race
    def race_select(m):
    if m == first:
    print('''What race would you like to be?
    Dwarf
    Elf
    Human
    Nixus''')
    race = lower(input())
    if not race == dwarf and not race == elf and not race == human and not race == nixus:
    print('That is not a race. Please try again')
    race_select(redo)
    else:
    print('You are now a% ' + str(race) + ".")

    race_select(first)
    -----------------------------------------------------------

    What I want it to do is when the function is used with the parameter as first, it shows the text, but if you put in an invalid race, it uses the function again, but you don't see the text again. How do I get this to work?

    Everything is indented correctly, it just doesn't show.

    (this is in the latest version of python, if you need to know)
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Location
    Canada
    Posts
    51
    Rep Power
    2
    Originally Posted by Draconic
    Hi, I am very new to python, and have started making a Text based game, but there is a problem.
    -----------------------------------------------------------
    # Welcomes player and select name
    name = input('''Welcome to Text RPG.
    A world of magic and adventure awaits!
    What is your name?
    ''')
    print('Hello ' + str(name) + '!')

    # Function for choosing player race
    def race_select(m):
    if m == first:
    print('''What race would you like to be?
    Dwarf
    Elf
    Human
    Nixus''')
    race = lower(input())
    if not race == dwarf and not race == elf and not race == human and not race == nixus:
    print('That is not a race. Please try again')
    race_select(redo)
    else:
    print('You are now a% ' + str(race) + ".")

    race_select(first)
    -----------------------------------------------------------

    What I want it to do is when the function is used with the parameter as first, it shows the text, but if you put in an invalid race, it uses the function again, but you don't see the text again. How do I get this to work?

    Everything is indented correctly, it just doesn't show.

    (this is in the latest version of python, if you need to know)
    I just skimmed through so maybe I missed it but first either needs to be a string or be defined. so either 'first' or 'first = '
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Location
    Canada
    Posts
    51
    Rep Power
    2
    actually the "if not race == races" the races should be strings too as they would be undefined too.

IMN logo majestic logo threadwatch logo seochat tools logo