score = int(input("Enter your score: "))
if not score < 0:
if score.isdigit():
if score > 100 and score < 0:
grade = 'Between 0 and 100'
else:
grade = 'asd'
else:
grade = 'Please enter a number'
else:
grade = 'negative numbers cannot be entered'
print(grade)
'int' object has no attribute 'isdigit'
There's an error that doesn't match the integer shape. Please tell me where to modify the shape.
python
It's probably because isdigit is a command to check strings. If the string is entered in the first place, the int conversion operation results in an error. Try configuring it as follows.
score = input ("Please enter a score"). : ")
try:
score = int(score)
except:
Rise Exception ('Please enter a number')
if not score < 0:
if score > 100 and score < 0:
grade = '0 to 100.'
else:
grade = 'negative number entered.'
print(grade)
© 2024 OneMinuteCode. All rights reserved.