-2

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

bashrc
  • 4,725
  • 1
  • 22
  • 49
gupta
  • 51
  • 4
  • 1
    If you're just starting to learn Python, you should take the time to actually learn it instead of simply asking for answers. – TigerhawkT3 Jan 11 '17 at 08:19

1 Answers1

-1

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)
bashrc
  • 4,725
  • 1
  • 22
  • 49
  • Any idea why the downvote? I am not a native english speaker so not sure if there is any mistake in the way this is conveyed, but I am sure the answer doesn't states anything incorrect. – bashrc Jan 11 '17 at 09:47