[Tutor] How to check if user input is an integer

Alan Gauld alan.gauld at btinternet.com
Fri Mar 29 19:14:21 CET 2013


On 29/03/13 12:34, Alan Gauld wrote:

A slight tweak to the solution; you probably need:

> So in pseudo code you should have

while True:
      read input
      if exit condition break
      try:
         convert to int
         break
      except ValueError: continue
process the value

HTH

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/



More information about the Tutor mailing list