My code–
match key: case list(map(ord, map( str, range(1,10) )): #...
this map function makes this format–
[ord('1'), ord('2'), ord('3'), ...]
from 1 to 9
But want like [ord('1') | ord('2') | ...]
How can i do that?
Advertisement
Answer
Try:
match key: case key if key in map(ord, map( str, range(1,10))): #...
Note: instead of double map
use a comprehension:
>>> [ord(str(i)) for i in range(1, 10)] [49, 50, 51, 52, 53, 54, 55, 56, 57]