Код: Выделить всё
import random
d = {}
with open('StatesCapitals.txt') as f:
for line in f:
key, value = line.split(',')
d[key] = value
HI = random.choice(list(d.keys()))
print(HI)
answer = (d[HI])
print (answer)
StudentAnswer = (input('Type your answer: '))
if answer.lower() == StudentAnswer.lower():
print('Correct!')
else:
print('Wrong.')
пример того, как выглядит мой файл StatesCapitals.txt
Подробнее здесь: https://stackoverflow.com/questions/610 ... en-its-not
Мобильная версия