Nov-06-2017, 07:12 PM
(This post was last modified: Nov-06-2017, 07:16 PM by gruntfutuk.)
You've only defined
age
in the function user_input
. It is private to that function and not available outside of that function. You either need to pass the parameters you want to share in the first place as arguments or return the information you require from the function (with due regard for the data structures you are using).Output:>>> def user_input():
... answer = input('Enter something: ')
...
>>> user_input()
Enter something: Have a nice day
>>> answer
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'answer' is not defined
>>>
I am trying to help you, really, even if it doesn't always seem that way