Hello,
I have this problem : Write a function named readposint that prompts the user for a positive integer and then checks the input to confirm that it meets the requirements. A sample session might look like this: >>> num = readposint() Please enter a positive integer: yes yes is not a positive integer. Try again. Please enter a positive integer: 3.14 3.14 is not a positive integer. Try again. Please enter a positive integer: -6 -6 is not a positive integer. Try again. Please enter a positive integer: 42 >>> num 42 >>> num2 = readposint("Now enter another one: ") Now enter another one: 31 >>> num2 31 >>> Now I thought this would work:def readposint(): x = raw_input("Please enter a positive integer :") try: x = int(x) and x > 0 except: print x , "is not a positive integer. Try again." return False return Truey = readposint() print y while y == False: readposint() print "You have entered : ", yBut the x > 10 is never checked.Must I use two try except now ? Roelof
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor