Предмет: Информатика, автор: Snowy71

Привет, подскажите пожалуйста, почему мой код, который написал для проекта в школе, но почему-то выдаёт предупреждение об синтаксической ошибке, в is not, но я не знаю, как это исправить. (писал в юпитер ноутбук).
вот код:
print('hi lets play!')
print('type you name')
name = input()
print('ok, your name is', name, '?')
name_question = input()
if name_question == 'no':
print('type your name correctly')
new_name = input()
print('please restart your game,', new_name) # конец пути
elif name_question is not 'no':
print('ok,', name, 'I hape you are ready, cos we are gonna play now!')
print('first question is: 8*210') # первый вопрос 1680
answer1 = input()
if answer1 == '1680':
print(name, 'correct!')
elif answer1 is not '1680':
print(name, 'restart your game, you lose(')
print('second question is: translate 1 (one) into german language (with letters)')
answer2 = input()
if answer2 == 'eins':
print('Correct! You are doing well,', name)
elif answer2 is not 'eins':
print(name, 'restart your game, you lose(')
print('ok, the last qestion will be... do you like my game?')
answer4 = input()
if answer4 == 'yes':
print('Thank you alot!')
elif answer4 == 'no':
print('sorry, I worked hard:(')
print('Thats all:)')

Ответы

Автор ответа: DmitriyM02
2

Ответ:

Вместо if (переменная) is not (Значение)

необходимо писать так:

if not (переменная) == (значения)

Исправленный (рабочий) код:

print("hi lets play!")

name = input("type you name")

print('ok, your name is', name, '?')

name_question = input()

if name_question == 'no':

   print('type your name correctly')

   new_name = input()

   print('please restart your game,', new_name) # конец пути

elif not name_question == 'no':

   print('ok,', name, 'I hape you are ready, cos we are gonna play now!')

print('first question is: 8*210') # первый вопрос 1680

answer1 = input()

if answer1 == '1680':

   print(name, 'correct!')

elif not answer1 == '1680':

   print(name, 'restart your game, you lose(')

print('second question is: translate 1 (one) into german language (with letters)')

answer2 = input()

if answer2 == 'eins':

   print('Correct! You are doing well,', name)

elif not answer2 == 'eins':

   print(name, 'restart your game, you lose(')

   print('ok, the last qestion will be... do you like my game?')

answer4 = input()

if answer4 == 'yes':

   print('Thank you alot!')

elif answer4 == 'no':

   print('sorry, I worked hard:(')

print('Thats all:)')


Snowy71: спасибо большое!
DmitriyM02: не за что, удачи )
Похожие вопросы
Предмет: Русский язык, автор: nnurane87
Предмет: Математика, автор: Лера233х