[Tutor] iterators

boB Stepp robertvstepp at gmail.com
Mon Jul 4 17:57:25 EDT 2016


On 07/04/2016 03:38 PM, Colby Christensen wrote:
> 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 believe that for (27) to be a tuple, you must insert a comma:  (27,).

boB


More information about the Tutor mailing list