This question already has an answer here:
- Replacements for switch statement in Python? 48 answers
if key == '1':
key = opt1
if key == '2':
key = opt2
if key == '3':
key = opt3
if key == '4':
key = opt4
if key == '5':
key = opt5
if key == '6':
key = opt6
if key == '7':
key = opt7
if key == '8':
key = opt8
if key == '0':
key = opt0
if key == '':
key = '-'
It looks terrible!! Is there a more elegant way to achieve the same result? Thanks in advance <3
Aucun commentaire:
Enregistrer un commentaire