首页 > 解决方案 > 输入函数后的行未执行

问题描述

我正处于 python 的最初阶段。当我试图通过打印语句打印我输入的值时,它不起作用。我的输入没有结束,它取值但不会进入下一行的打印语句。

def addition(A,B):
    return A+b
Value1 = input("Enter the Value1:")
print(Value1)

标签: python-3.x

解决方案


您需要调用您的函数并整理变量名称,因为它们不同且不符合 PEP8。最终的工作版本将是:

def addition(a,b):
    return a+b


value1 = int(input("Enter the Value1:")) # The reason I call int here is input() returns a string.
value2 = int(input("Enter the Value2:"))
print(addition(value1, value2)

推荐阅读