0
What's wrong in this code?. I can't able to find anything!* . Need a help.
n=0 max=1 x=int(input("enter a value")) while n<100; if x== -1; print (max) elif x>max; max=x else n=n+1 print ("the max number is",max)
7 Respuestas
+ 3
n=0
max=1
x=int(input("enter a value"))
while n<100:
if x== -1:
break
elif x>max:
max=x
else:
n=n+1
print ("the max number is",max)
+ 3
Abhay Don't put else statement at n = n + 1
+ 2
Put colon instead of semi colon
You can send the link of your code
+ 2
Dont put else....
As it will show an error of RecursionError
because for some cases it is an infinite loop
+ 2
I even don't know why it was there ,but I didn't want to remove it so i left it there
+ 1
Thanks! Namit Jain and Abhay .Now it works 👍
+ 1
n += 1 is necessary in order not to get an error