Answer the question
In order to leave comments, you need to log in
How to answer examples?
The program displays an example and you need to enter the correct answer, but I can’t even figure out how to indicate the correct answer to the examples.
import random
import time
#список
list = ["4+4", "3*4", "3+7", "9-7"]
#вывод рандомного слова
vivod = random.choice(list)
print(vivod)
#ввод юзером ответ примера и проверка
user = input()
if vivod == user:
print("Верно")
else:
print("Ошибка")
Answer the question
In order to leave comments, you need to log in
Either write it right away normally, through the same dictionary (it will be best), or through literal_eval
1.
questions = {'4+4': 8, '3*4': 12, '3+7': 10, '9-7': 2}
question, answer = random.choice(list(questions.items()))
user = int(input())
if answer == user:
# ...
from ast import literal_eval
if literal_eval(vivod) == user:
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question