I'll start by saying that I did look up answers to this question and unfortunately, I just couldn't understand them or they didn't seem to work for me. This is of course down to me rather than the people who answered the question, so I do apologise in advance.
So pretty much I'm trying to call a variable that is assigned by the user from one function to the other, I'll give an example:
def function_one():
a = input("What is your name?")
return a
def function_two():
print("Nice to meet you, "a)
function_one()
function_two()
This of course does not work and I'm sure that is down to my own stupidity, I wasn't sure why at first because I saw other people saying to simply return the variable, which I did!
I also tried calling the variable from the other function, for example:
def function_two()
a = function_one()
but I realised that was pretty stupid since I'm just assigning that function as a, so it's not going to work.
I'd appreciate some insight, I know these are not the kind of questions you'd expect but yeah... I'm clueless.
a = function_one(). For second function, you need to pass that value stored in a to the function or useglobal ato use global variable. To pass the function:def function_two(a)will mean it will get variableaas parameter and call it asfunction_two(a)will give the result. You can also do something likefunction_two(function_one())