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
8 odpowiedzi
+ 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")
+ 3
Use float(input()) ,you might be using decimals
+ 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
+ 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.
+ 1
Dont see any error on what platform are you running the code sololearn?
+ 1
Lz1234 visual studio code
+ 1
Lz1234
Yeah, I've found an alternate way of putting it, thanks
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')