在Python中,我总是得到错误消息

2024-03-28 11:48:45 发布

您现在位置:Python中文网/ 问答频道 /正文

嘿,我对编程和python完全陌生,不知道我在第一个程序中做错了什么。我试着在谷歌上搜索,但是我找到并尝试的所有其他解决方案都不起作用,我总是收到同样的错误消息。也许有人能告诉我我做错了什么吗?:)

我希望我能够乘法,直到我在最后一个输入中输入no。在

welcome = "Welcome to Multiplyer!!!"
print(welcome)
name = input("Hello, please input your name: ")
print("Hello " + name + ", thank you for using Multiplyer")

while True:
print("Select two numbers")

num1 = int(input("Number 1: "))
num2 = int(input("Number 2: "))


print(num1 * num2)

 n = raw_input("Wanna multiply again? ")
    if n.strip() == 'no':
        break

Tags: noname程序numberhelloinput编程解决方案
2条回答

在Python中,缩进是语言的一部分,因此while循环的内容应该缩进:

welcome = "Welcome to Multiplyer!!!"
print(welcome)
name = input("Hello, please input your name: ")
print("Hello " + name + ", thank you for using Multiplyer")

while True:
    print("Select two numbers")

    num1 = int(input("Number 1: "))
    num2 = int(input("Number 2: "))


    print(num1 * num2)

    n = input("Wanna multiply again? ")
    if n.strip() == 'no':
        break

试试这个:

welcome = "Welcome to Multiplyer!!!"
print(welcome)
name = input("Hello, please input your name: ")
print("Hello " + name + ", thank you for using Multiplyer")

while True:
    print("Select two numbers")

    num1 = int(input("Number 1: "))
    num2 = int(input("Number 2: "))


    print(num1 * num2)

    n = raw_input("Wanna multiply again? ")
    if n.strip() == 'no':
        break

相关问题 更多 >