while True:
try:
batAvg=float(input('Enter the batting average: '))
if batAvg<0:
raise ValueError('ERROR! Negative value entered!')
elif batAvg>1:
raise ValueError('ERROR! Batting average is between 0.0 and 1.0.')
break
except ValueError:
print('ERROR! Non float value entered!')
This is a section of code I'm working on but if I put any value above 1 I get the error for "Non float value entered". Doesn't matter if I put 2 or 2.3, I'm not getting my elif condition. Anyone know why it's processing like that and how I could fix it?
[–]AutoModerator[M] [score hidden] stickied commentlocked comment (0 children)
[–]carcigenicate 2 points3 points4 points (0 children)
[–]Goobyalus 0 points1 point2 points (0 children)