-2

The code works when I don't use raw_input. Not sure what I am doing wrong. I am using python 2.7.5 Here is my code:

mark = raw_input('Enter Your Marks: ')

x = mark

if x > 80:
    grade = 'HD'
elif x > 70:
    grade = 'D'
elif x > 60:
    grade = 'CR'
elif x > 50:
    grade = 'P'
else:
    grade = 'F'

print(grade)
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
user1951876
  • 294
  • 2
  • 5
  • 16
  • 3
    You need to convert the value from a string to an integer before you can compare it with other integers meaningfully. – Charles Duffy Jun 15 '14 at 01:43

1 Answers1

2

raw_input() returns a string, but you are comparing against integers.

Convert your input:

x = int(mark)
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343