首页 > 解决方案 > 我正在努力找出这段代码有什么问题

问题描述

所以我一直在测试我创建的一个简单的乘法游戏。似乎答案变量与 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!")

标签: python

解决方案


推荐阅读