[Tutor] Re: Why can't I make this function work?
smith-matt at tiscali.co.uk
Fri Jul 16 17:32:54 CEST 2004
On Thu, 15 Jul 2004 20:35:56 +0100, Matt Smith wrote:
> I have written the following function as part of my guessing game program
> (as discussed in another thread):
> def Get_int():
> "Function to collect an integer from the user"
> type_check = 0
> while type_check == 0:
> int = raw_input()
> if type(int) != type(1):
> print "Invalid input"
> type_check = 1
> return int
Thanks for the help, I've re-written the funcion as below and it seams to
work correctly now.
"Function to collect a integer from the user"
type_check = 0
while type_check == 0:
integer = int(raw_input())
type_check = 1
print "Invalid input, try agin. ",
More information about the Tutor