score = raw_input("Enter Score: ")
try:
s = float(score)
except:
print "Error"
quit()
if s >= 0.9:
print "A"
elif s >= 0.8:
print "B"
elif s >= 0.7:
print "C"
elif s >= 0.6:
print "D"
else:
print "F"
Asked
Active
Viewed 126 times
-1

jonrsharpe
- 115,751
- 26
- 228
- 437
1 Answers
0
In place of quit() i recommend you to use sys.exit(0)
import sys
score = raw_input("Enter Score: ")
try:
s = float(score)
except:
print "Error"
sys.exit(0)
if s >= 0.9:
print "A"
elif s >= 0.8:
print "B"
elif s >= 0.7:
print "C"
elif s >= 0.6:
print "D"
else:
print "F"
if you are using python 3 then use parenthesis with print function
** Best Way **
score=input()
try:
s=float(score)
if(s>=0.9):
print("A")
elif(s>=0.8):
print("B")
elif(s>=0.7)
print("C)
except:
print("error")

Welcome_back
- 1,245
- 12
- 18