Home Using variables from separate functions in Python?
 I am currently working on a coding project where I have set several functions. I am trying to figure out how to use variables from different function. I have tried using 'self' but it hasn't worked. Can anyone help me sort out my code? class A(object): def intro1(self): print("Welcome to the XXCI forum!") self.intro2() def intro2(self): print("Press 'L' to log in and 'S to sign up.") ch1 = input() if ch1 == 'l' or 'L': self.log_in() elif ch1 == 'S' or 's': self.sign_up1() else: print("Your input was invalid") self.intro2() def sign_up1(self): print("Please enter your first name:") fn1 = input() if len(fn1) >= 3: self.sign_up2() elif len(fn1) <3: print("Please enter a name that is equal to or over three characters!") self.sign_up1() def sign_up2(self): print("Please enter your last name.") ln1 = input() if ln1 == ln1: with open(ln1.txt, "a") as ln1: ln1.write("Age: " + ag1 + ".") sign_up3() def sign_up3(): print("Please enter your age.") ag1 = input() if ag1 > 90: print("Please enter an age under 90 and equal to 16 or over.") elif ag1 <16: print("Please enter an age under 90 and equal to 16 or over.") else: user_g() def user_g(): username = (fn1[3], str[ag1]) username.join'' print("Here is your username:") print(username) p_creator()  It's obviously not finished yet, but I would really appreciate guidance with how to correct my errors and use variables in different functions. Thank you very much!!