Код: Выделить всё
inventory = []
print "You can choose 2 items from the following:"
print "Gun, Grenade, Smoke bomb. Type your weapon choices now: "
try:
choice1 = raw_input("Choice 1: ")
inventory.append(choice1)
except:
if choice1 not in ('gun', 'grenade', 'smoke bomb'):
raise Exception("Please enter one of the 3 choices only only")
Я знаю, что я могу заставить это работать другими способами, например, поместив цикл while после raw_input, чтобы проверить, что было введено по этим трем элементам, но я хочу сделать это с помощью try и кроме.
Подробнее здесь: https://stackoverflow.com/questions/350 ... user-input