How restart loop after enum's execution?
Question:
Have a problem with my loop. How loop can be restarted after picking one of the numbers (as input) in "pick" IntEnum?
Any ideas?
from enum import IntEnum
Menu = IntEnum('pick', 'SAEMP25N SAEMP27N SAGDP1 SAGDP9N
SAGDP6N SAINC5N SAINC6N SAPCE2')
pick = int(input("""
Pick number:
1. SAEMP25N
2. SAEMP27N
3. SAGDP1
4. SAGDP9N
5. SAGDP6N
6. SAINC5N
7. SAINC6N
8. SAPCE2
"""
))
while pick < 8:
if pick == Menu.SAEMP25N:
print('nice')
continue
if pick == Menu.SAEMP27N:
print('nice')
continue
else:
print('..')
Answers:
Right now you’re asking for input once, you need to do it repeatedly inside the loop:
while True:
pick = int(input(""" .... """))
if pick == Menu.SAEMP25N:
print('nice')
if pick == Menu.SAEMP27N:
print('nice')
else:
print('..')
if pick == 8:
break
Have a problem with my loop. How loop can be restarted after picking one of the numbers (as input) in "pick" IntEnum?
Any ideas?
from enum import IntEnum
Menu = IntEnum('pick', 'SAEMP25N SAEMP27N SAGDP1 SAGDP9N
SAGDP6N SAINC5N SAINC6N SAPCE2')
pick = int(input("""
Pick number:
1. SAEMP25N
2. SAEMP27N
3. SAGDP1
4. SAGDP9N
5. SAGDP6N
6. SAINC5N
7. SAINC6N
8. SAPCE2
"""
))
while pick < 8:
if pick == Menu.SAEMP25N:
print('nice')
continue
if pick == Menu.SAEMP27N:
print('nice')
continue
else:
print('..')
Right now you’re asking for input once, you need to do it repeatedly inside the loop:
while True:
pick = int(input(""" .... """))
if pick == Menu.SAEMP25N:
print('nice')
if pick == Menu.SAEMP27N:
print('nice')
else:
print('..')
if pick == 8:
break