[Tutor] iterators

Colby Christensen colbychristensen at hotmail.com
Mon Jul 4 16:38:01 EDT 2016


I'm sure this is something simple but I'm missing it. 
When I check the statement with two values, the if statement works. However, for the statement with one value I get an error.
keycode = event.GetKeyCode()
if keycode in (13, 370):
    self.enter()
elif keycode in (43, 388):
    self.add()
elif keycode in (45, 390):
    self.sub()
elif keycode in (42, 387):
    self.mult()
elif keycode in (47, 392):
    self.div()
elif keycode in (27):
    self.clear_all()
elif keycode in (67, 99):
    self.display.SetValue('')
else:
    event.Skip()This is the error message.
Traceback (most recent call last):
  File "/home/colby/Calculator/Calculator_betaV3.py", line 110, in OnKeyPress
    elif keycode in (27):
TypeError: argument of type 'int' is not iterable

I then tried using

elif keycode == 27:

but this statement didn't work. 

I'm pretty sure it's something simple that I've overlooked due to my inexperience.

Thanks in advance.
 		 	   		  


More information about the Tutor mailing list