Python Forum
Issues with functions
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Issues with functions
#3
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
Reply


Messages In This Thread
Issues with functions - by kiki1113 - Nov-04-2017, 01:53 AM
RE: Issues with functions - by Larz60+ - Nov-04-2017, 03:27 AM
RE: Issues with functions - by gruntfutuk - Nov-06-2017, 07:12 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020