I have this code.
c = getch()
if c == "r":
return randrange(101, len(mylist) - 1)
if c == "u":
return 100
if c == "b":
return -2
if c == "w":
return -3
if c == "m":
return -4
if c == "d":
return -5
if c == "e":
return -6
if c == "k":
return -7
if c == "g":
return -8
if c == "p":
return -9
if c == "o":
right = center - 1
else:
left = center + 1
Can I make this code snippet more compact? How would you write it better?
thank you
You can use a dictionary: