python - 我正在努力找出这段代码有什么问题
问题描述
所以我一直在测试我创建的一个简单的乘法游戏。似乎答案变量与 question3 相同,因为我已将它们打印出来以查看值,但它仍将其归类为不相等。我已将它们注释掉,以便您知道我做了什么。
import random
# Variables
number1 = random.randint(0, 12)
number2 = random.randint(0, 12)
answer = number1 * number2
#print(answer)
question = print("What is", number1,"x", number2, "?")
# Game loop
for i in range (1):
question2 = input()
question3 = question2
#print(question2)
if question3 == answer:
print("Well done!")
elif question2 != answer:
print("Wrong!")
解决方案
推荐阅读
- c++ - 在 C++ 中反转数字的数字
- html - 同一行中的 HTML 2 列,标题和段落与图像垂直居中
- c - 使用按位运算乘以 3
- protractor - 如何使用打字稿(量角器+黄瓜)执行 beforeTest 和 afterTest 方法
- javascript - 如何在@require(Greasemonkey)中使用自定义变量
- python - 即使我安装了包,在 makefile 上构建 python 包时出错
- python - 使用 dict.get() 的斐波那契数列和 RecursionError
- shell - 分隔符出现次数后拆分文件
- r - 在闪亮的第一个默认值后隔离输入
- python - 当 pos_hint 以编程方式更改时,为什么 kivy 不更新小部件的位置?