Consider this code:
>>> num = int(raw_input('Enter the number > '))
If the user does not type anything and presses 'Enter', I want to capture it. (Record the empty input)
There are two ways to do this:
- I make it simple
num = raw_input()and then check if there is any num == ''. Subsequently, I can apply it to int. - I will catch
ValueError. But in this case, I cannot distinguish between non-numeric input and empty input.
Any suggestions on how to do this?
source
share