[sf-lug] ThinkPython: coding problem
a_kleider at yahoo.com
Fri Oct 10 21:42:27 PDT 2008
# ThinkPython: question-
As part of our ThinkPython class exercises I want to
check user input.
i.e. the user is asked to enter a number and I want the routine
to check that it is indeed a number that is entered.
It seems that everything "collected" by raw_input is considered
a string, even if only digits are included.
return True # as used below, NEVER returns True.
response=raw_input('enter a number: ')
pass #procede with what needs to be done
pass #take corrective action
Can anyone suggest how I can accomplish this?
I'm familiar with Pascal and its strong typing which would prevent such a problem from occurring as a runtime problem (vs a syntactic error.)
More information about the sf-lug