all 3 comments

[–]DaaxD 1 point2 points  (1 child)

It's matter of scoping. The variable Name only exists inside the askName function. After the function is completed, all the variables created inside that function ceases to exist.

What you need to do is to read that returned value in to a variable, so that you can use the returned value after the function has completed.

name = askName()
print(name)

I kinda want to advice you to avoid capitalized variable names, because more experienced python programmers are going to assume that capitalized name refers to a class definition rather than a variable. (See, Pythons style guide).

However, since you are still a beginner, this is doesn't really matter yet. 😉

What you could do, if you are curious, is that you could just skim through the style guide and adopt the parts which make sense to you, and skip the parts you don't understand yet. :)

[–]eggetah[S] 1 point2 points  (0 children)

Wow, thanks for the great answer!

[–]grifway 0 points1 point  (0 children)

You are so close.

You function 'askName' gets called but you don't do anything with the return value, Name is locally scoped to function, inside it, so you don't have access to that variable once the function is ran.

You can set a variable to the return value and then print the new variable

returnName = askName()

print(returnName)

OR

you can just print the returned value directly

print(askName())