Just did Problem Set 0. Had a question regarding raw_input in newer versions. In version 2.5.4 of Python this works just fine, however in pasting to codepad for evaluation here, it returns an error: http://codepad.org/gYsxP6ve What is the proper syntax for input in newer versions of Python?
In newer versions of Python the proper command is simply 'input()' It is a change that appears to have been made in Python 3.
I tried just using input() in place of raw_input () and still come back with the same EOFError. Can you help me understand what's wrong? http://codepad.org/HrNiKFwL
The error is on codepad, since you didn't pass the input for it. You just ran the code, but codepad has no way whatsoever to accept input from you, hence the error of end of file. As a matter of style, functions calls are generally used with no space before parenthesis, and a space between the assignment operator, like: answer = raw_input() Other thing is that you can pass a string as a parameter for raw_input, and it will prompt the user, like: answer = raw_input('Enter your name here: ')
Thanks bmp! That simplifies the code quite a bit. And thanks for explaining why codepad was returning an error.
Join our real-time social learning platform and learn together with your friends!