def great(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")
a=great(12,3,1)
print(a)
Can you explain why none is printing in output?
CodePudding user response:
In python indentation matters, Your Function Call is not Properly indented that is why it is not printing anything
def great(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")
a=great(12,3,1)
print(a)
CodePudding user response:
Because your great function is returning None.
Here is the solution:
def great(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")
great(12,3,1)
CodePudding user response:
function great() does not return anything. In python, when nothing is returned in a function, a default 'None' value is returned. So when use:
a=great(12,3,1)
it returns None value. That value is assigned to a. Therefore, when you print a you get None.
Check out this link for more:
