What's wrong in this code?, it is returning none when called! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What's wrong in this code?, it is returning none when called!

x=48 y=18 def gcd(a,b): quot=a/b if quot>0: rem=a%b if rem>0: e=b%rem quot=quot-1 a=b b=e else: print(rem) else: print(quot) gcd(x,y)

17th Mar 2019, 10:51 AM
Mohd Adnan
Mohd Adnan - avatar
3 Answers
+ 3
Both print statements are in the ‘else’ blocks. As it is written, both of your ‘if’ statements will return True, so neither print statements will be executed.
17th Mar 2019, 11:06 AM
Russ
Russ - avatar
+ 1
Thanks for your answer sir
17th Mar 2019, 11:16 AM
Mohd Adnan
Mohd Adnan - avatar
0
It is not printing anything though i wrote a print statement in function Return statement is missing intentionally
17th Mar 2019, 10:52 AM
Mohd Adnan
Mohd Adnan - avatar