0

vraag = int(raw_input("Hoeveel euro aan eten gaat John vandaag eten?"))

while vraag != int():
    vraag = raw_input("Vul alstublieft een geheel getal in: ")
  
if vraag >= 10:
  print "Bent u gek ofzo! Denkt u serieus dat John voor %s euro gaat eten!?" % vraag

else:
  print "John gaat inderdaad voor %s euro aan eten eten!" % vraag

So basically I want the user to put in a number (vraag = question in Dutch), otherwise it'll prompt a message (under while vraag... : "Please typ in an integer), but it doesn't work. Can someone please tell me how I should do this? I'm really new to Python.

  • See this SO question on checking for whether a string is an int: https://stackoverflow.com/questions/3501382/checking-whether-a-variable-is-an-integer-or-not – gandreadis Jul 03 '17 at 12:45
  • @gandreadis no: inputting a string containing digits won't make the result anymore `int`. – Jean-François Fabre Jul 03 '17 at 12:47
  • @Jean-FrançoisFabre That's true, but I was referring to the `while` conditional check the OP is doing on line 3, which does need some form of integer checking. Still, you are absolutely right, the actual casting needs other operations ;) – gandreadis Jul 03 '17 at 12:54

0 Answers0