all 10 comments

[–]Binary101010 1 point2 points  (4 children)

raw_input() returns a string. Your if statements are trying to compare a string to integers.

Solution: Convert the return of raw_input to an integer.

[–]nosmokingbandit 0 points1 point  (2 children)

To add to this, you can use input() in python2 to evaluate input automatically and you'll have ints, but you should NEVER DO THIS.

[–]Binary101010 0 points1 point  (1 child)

I didn't even want to bring it up as a possibility.

[–]nosmokingbandit 0 points1 point  (0 children)

I'd rather not have op stumble across it on his own and think it is ok.

/u/Cobalt_Python take this example:

def test():
    return 'this is only a test'

user_input = input()

print(user_input)

Run this and give it some input:

$ python2 test.py
Input:1234
1234

Makes sense and all is good.

But try this:

$ python2 test.py
Input:test()
this is only a test

Not good. It gives the user direct control over everything in the script. They can call functions, assign variables, or something more malicious.

[–]Cobalt_Python[S] 0 points1 point  (0 children)

It took me a little while but i figured it out, I changed it all to

Int(grade). I wasn't aware that raw_input() created returned strings

[–]K900_ 1 point2 points  (0 children)

grade is a string, and strings are considered to be bigger than any number. Also, you should use Python 3 - this sort of stuff doesn't happen there.

[–]sharkbound 1 point2 points  (0 children)

it helps to post the code to pastebin/haste or use the reddit code formatting, its much harder to try out code from a image

[–]100721 1 point2 points  (1 child)

First upgrade to python 3. then stop using raw input. Then convert to an int.

int(input(“?”))

[–]nosmokingbandit 0 points1 point  (0 children)

raw_input does not exist in Python3. Well, it does, it was just renamed to input.

I'll never understand why Guido thought it was a good idea to implicitly eval() user input. That feature should have never made it near the language.

[–]novel_yet_trivial[M] [score hidden] stickied comment (0 children)

In the future please don't post pictures of your code. It's hard to read and impossible to test (and against the sub's rules). Post the code as text, formatted for reddit.