0

Is there an error somewhere here?

I keep getting error each time I run this code. Any suggestions as to what I'm doing wrong? https://code.sololearn.com/c7BpyQE7Nw1d/?ref=app

19th Oct 2021, 9:54 PM
Bryte
Bryte - avatar
8 Answers
+ 2
Or you could do something like this: grade = input() if(grade.isnumeric()): grade = int(grade) # your code else: print("This is not a number")
20th Oct 2021, 4:00 AM
Stefanoo
Stefanoo - avatar
+ 3
Use float(input()) ,you might be using decimals
20th Oct 2021, 5:14 AM
Prabhas Koya
+ 2
Is it working yet I see that if put in float or string it gives error on sololearn but if i put input its fine
20th Oct 2021, 5:18 PM
Lz1234
+ 1
It depends on your input, if you type in a number it works fine. But if you enter a string it raises an ValueError.
19th Oct 2021, 10:24 PM
Stefanoo
Stefanoo - avatar
+ 1
Dont see any error on what platform are you running the code sololearn?
19th Oct 2021, 10:24 PM
Lz1234
+ 1
Lz1234 visual studio code
20th Oct 2021, 5:15 PM
Bryte
Bryte - avatar
+ 1
Lz1234 Yeah, I've found an alternate way of putting it, thanks
20th Oct 2021, 5:26 PM
Bryte
Bryte - avatar
0
You can use try and except to rise an exception if the user writes a string value Like try: grade=..... Except: Print('not a number')
20th Oct 2021, 2:04 AM
Daniel RodrĂ­guez
Daniel RodrĂ­guez - avatar