Issue
Sorry for the title but I'm not sure how else to word it. Anyway I'm just starting to learn Python and ran into this problem. I'm trying to assign a variable to a function call, where the function contains input()
Unfortunately this never assigns anything to the variable a
def question(letter):
input(letter + '? ')
a = question('a')
print(a)
So I guess my real question is, why doesn't that work? Why doesn't it assign the user input to the variable a
?
Thanks
Solution
You need to return
the user input. Right now the user input is captured nowhere.
def question(letter):
return input(letter + '? ')
a = question('a')
print(a)
Answered By - bashrc
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.