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)

27th May 2020, 9:29 AM
Dinesh Aaryan
Dinesh Aaryan - avatar
7 Answers
+ 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)
27th May 2020, 9:37 AM
Abhay
Abhay - avatar
+ 3
Abhay Don't put else statement at n = n + 1
27th May 2020, 9:45 AM
Namit Jain
Namit Jain - avatar
+ 2
Put colon instead of semi colon You can send the link of your code
27th May 2020, 9:32 AM
Namit Jain
Namit Jain - avatar
+ 2
Dont put else.... As it will show an error of RecursionError because for some cases it is an infinite loop
27th May 2020, 9:39 AM
Namit Jain
Namit Jain - avatar
+ 2
I even don't know why it was there ,but I didn't want to remove it so i left it there
27th May 2020, 10:07 AM
Abhay
Abhay - avatar
+ 1
Thanks! Namit Jain and Abhay .Now it works 👍
27th May 2020, 9:41 AM
Dinesh Aaryan
Dinesh Aaryan - avatar
+ 1
n += 1 is necessary in order not to get an error
27th May 2020, 10:08 AM
Namit Jain
Namit Jain - avatar