Not working - 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: Not working (/thread-8548.html) |
Not working - tommytime555 - Feb-25-2018 Hi... I am pulling my hair out trying to figure out why this isn't working. The functions are working fine, but then after running through the functions the value of (name) no longer works.. Bottom line, I'm just wanting it to print (name) at the end. That's it. def AskForLastName(): last = input('your last name?') print ("Nice meating you.Have a good day") def AskForName(): name = input('What is your first name:') if len(name) >=4: print ('hello (:') AskForLastName() elif len(name) <4: print('too short. 4 or more charecters') AskForName() AskForName() print (name) RE: Not working - Larz60+ - Feb-25-2018 you need to return name from the functions at end of each function, return what function creates: for example: def AskForLastName(): last = input('your last name?') print ("Nice meating you.Have a good day") return lastand when calling AskForLastName: lastname = AskForLastName() print(lastname) # or simply: print(AskForLastName()) |