0
Why this code shows no output?
def happy(m): b=m z=m c=0 while(z>9): while(b>9): c=((b%10)**2)+c b=b/10 z=c while(c==1): return "h" return "nh" a=19 print(happy(a))
3 Respostas
+ 4
I think, check that your loop is inifinite.
z>9 is always true because c is keeps on increseing. And so z by z =c So you have infinte loop..
Note:
b/10 floating division => 1.9
b//10 integer division => 1
+ 3
Why so many while loop?
What you want to do?
+ 3
Gani Ganesh
b = 19
z = 19
while 19 > 9: #true
while 19 > 9: #true
c = (19 % 10) ** 2 + 0 = 81
b = 19 / 10 = 1.9
z = 81
Now z became 81 and b became 1.9
So while 81 > 9:
This would be always True means Infinite loop
So while c == 1: would be never work.
That is why there is No output because of Stack overflow