Найти - Пользователи
Полная версия: Логические выражения
Начало » Python для новичков » Логические выражения
1
xxnikolayxx
Дорогие форумчане, толи я слишком мало сплю, то ли тут какая-то не понятная проблема.
loop = 3
n = True
while n:
    try:
        choice = int(raw_input('You choice: '))
    except ValueError:
        print 'ERROR: "{0}" not integer'.format(choice)
        loop -= 1
    else:
        if choice != 1 or choice != 2 or choice != 3 or choice != 4:
            print 'ERROR: "{0}" must be [1:4]'.format(choice)
            loop -= 1
        else:
            if choice == 4:
                import sys
                print 'By by'
                sys.exit(1)
            n = False
    if loop == 0:
        import sys
        print 'By by'
        sys.exit(1)
sergeek
or на and замени
а лучше на:
if choice not in (1,2,3,4):
или о чем ты там вообще
Budulianin
xxnikolayxx
Дорогие форумчане, толи я слишком мало сплю, то ли тут какая-то не понятная проблема.

Ты мало спишь, читай про ленивые вычисления
xxnikolayxx
sergeek
if choice not in (1,2,3,4):
Я и совсем забыл про not in.
Спасибо.
xxnikolayxx
Budulianin
ленивые вычисления
Первый раз слышу. Заценим.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB