Python variable inside of function not able to be called

I am making an rpg type thing with python and I made a few functions but I need to call variables that were stated and altered inside of a separate function. How would I be able to call a variable inside a function. My Code:

import time
def title():
  print("Hello Welcome To Elvoria")
  time.sleep(1)
  print("Choose Your Gender, Name, And Race")
  time.sleep(1)
def gnd():
  Gender = input("""Male, Female, Or NonBinary?
""")

  if Gender == ("Male"):
    genderin = 'Male'
  elif Gender == ("Female"):
    genderin = 'Male'
  elif Gender == ("NonBinary"):
    genderin = 'Male'
  else:
    gnd()
def nm():
  namein = input("""What Is Your Character's Name?
""")
  print("Welcome To Elvoria "+namein+"")
def rac():
  print("""The Race Options Are:
Elf-Good With Archery And Light Armor
Kelner-Good With Two Handed Weapons And Heavy Armor
Human-Good With Bows And Stealth
Mageine-Good With Magic And Speed""")
  time.sleep(1)
  racin = input("""Now Choose A Race
""")
  if racin == ("Elf"):
    print ("You Are Now A " + genderin + racin +" Named" + namein + "")
  elif racin == ("Kelner"):
    print ("You Are Now A " + genderin + racin +" Named" + namein + "")
  elif racin == ("Human"):
    print ("You Are Now A " + genderin + racin +" Named" + namein + "")
  elif racin == ("Magein"):
    print ("You Are Now A " + genderin + racin +" Named" + namein + "")
  else:
    print ("You Are Now A " + genderin + racin +" Named" + namein + "")
title()
time.sleep(1)
gnd()
time.sleep(1)
nm()
time.sleep(1)
rac()

And The Error Code:

   print ("You Are Now A " + genderin + racin +" Named" + namein + "")
NameError: name 'genderin' is not defined


Read more here: https://stackoverflow.com/questions/68464309/python-variable-inside-of-function-not-able-to-be-called

Content Attribution

This content was originally published by Student Aiden Kai MaKenzie at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: