【发布时间】:2016-02-22 20:12:27
【问题描述】:
我开始了我的代码
from random import randint, shuffle
numbers = {1:'\u4e00', 2:'\u4e8c', 3:'\u4e09', 4:'\u56db', 5:'\u4e94', \
6:'\u516d', 7:'\u4e03', 8:'\u516b', 9:'\u4e5d', 10:'\u5341'}
x=randint(1,10)
print('Welcome to our quiz on Chinese/Japanese numerals.')
input('What is the Value of ' +numbers[x] +'?' )
if 1 == '\u4e00' :
print('Congratulations! Let us continue then, consider:')
else:
print( 'Congratulations! Let us continue then, consider:')
input (['\u4e00', '\u4e8c', '\u4e09', '\u56db','\u4e94', \
'\u516d', '\u4e03', '\u516b', '\u4e5d', '\u5341'])
input ('At which position is the value of ' +numbers[x] +'?' )
我对代码的 if 和 else 部分有疑问。我已经能够通过询问初始问题并插入随机汉字来设置测验的开头,但是我遇到了一个问题,即“错误答案,____等于_____”。声明的一部分。我如何确定用户在提示中插入的内容是正确的还是不正确的?
【问题讨论】:
-
if user_input == right_answer?除非您实际分配用户的输入,否则这会有点棘手......
标签: python if-statement random input