"William Witteman" <y...@nerd.cx> wrote
I want to make sure that I actually get integers.
num_of_articles = 0
num_of_reviewers = 0
def getinput(variable,prompt):
"""
Get the input by prompting the user and collecting the response - if it
is
a non-integer, try again.
"""
variable = 0
variable = raw_input(prompt)
try:
int(variable)
return variable
The normal way in Python would be to combine this with
try:
return int(raw_input(....))
except ValueError:
blah...
except ValueError:
print("We need an integer (number) here.")
getinput(variable,prompt)
You don;t return the value from getinput().
Just add a return in front of the call...
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor