【发布时间】:2016-01-08 05:26:08
【问题描述】:
我用python编写了一个程序,它最多显示三个数字。虽然程序很简单,但输出提出了一个问题。这是我编写的代码:::
#Program to find maximum of three numbers using function
def max_of_three(a,b,c):
if(a>b and a>c):
print("a is greater")
elif(b>a and b>c):
print("b is greater")
else:
print("c is greater")
print("Enter three numbers...")
a=int(input())
b=int(input())
c=int(input())
print(max_of_three(a,b,c))
现在当我运行这个程序并在运行时提供输入后得到这个输出时::
Enter three numbers...
58
45
12
a is greater
None
结果很好..但我不明白为什么要打印“无”这个词?我的意思是什么意思?
【问题讨论】:
-
删除最后一个打印,即
max_of_three(a,b,c)就足够了,因为您在该函数中添加了printfunc。 -
Python 还允许您在条件下丢失
and,即如果 a > b > c:
标签: python function python-3.x