+ 3
Why is the output of this code: None 2
7 Réponses
+ 3
It will always return 1 in each condition. Here your fornication is acting just like a loop infact it is not a loop. by the way here result is 1 2
+ 2
The correct format should be like this:
def function(x):
if x == 1:
return x
else:
x -= 1
return x
function(x)
x = 2
print(function(x),x)
Kindly upvote if it works for you.
Thanks 😊
+ 1
Try running the code you get output as :
None 2
+ 1
But when you run the code we get output as:
None 2
+ 1
Thanks ,I understood
Can you upvote my question 😀
0
Second last line of your code has intendation, thus it is not a part of your function.
As a result of which value of x is 2. And when yoy call a function outside of its defination it returns none.