I am doing another project that is not related to any of the courses on Codecademy, but I am using it as my shell. The programming language that I am using is Python. Whenever I enter in raw_input() and I press Run, it shows my raw_input(), but it doesn’t let me input anything. It then also puts in that there is an EOFError: EOF when reading a line. How can I fix this? I can input the code here if needed.
EDIT: I can’t download anything btw, such as the Python shell or the PythonTkinter package.
Can you show a screenshot?
first = raw_input("Please input a number: ") if first.isnumeric(): second = raw_input("Please input a second number: ") if second.isnumeric(): third = raw_input("What would you like for the equation? Addition, subtraction, multiplication, or division. Input the sign please: ") if third == "+": done = first + second print "Your answer is " + done elif third == "-": done = first - second print "Your answer is " + done elif third == "*": done = first * second print "Your answer is " + done elif third == "/": done = first / second print "Your answer is " + done else: print "Sorry. The sign was not correct." else: print "That was not a valid number. Please try again later!"
And a screenshot as well? I want to see your code in action, and why it produces an EOF error
but you are working in codecademy
given each codecademy exercise has validation behind it, its not an ideal working environment for your own project.
if you can’t install anything (which i would recommend), at least use a site which is more designed for running your own code snippets. something like repl
I have tried repl.it as well, but it still puts in the same error. I believe it has something to do with my code, but I cannot verify it. Yes I am using Codecademy, but it is just a shell. My Python 3.7 shell doesn’t work with this code as well.
I also have another piece of code that I am working on, but it doesn’t work as well, since I also have raw_input() in it. It is a Sudoku game, but the code is incomplete. I have tried it in multiple different websites, such as this and repl.it and also another one that is called tutorialpython, but it still shows the same error.
using a different major python version can indeed create a problem.
raw_input() is a python2 function. Other things count as well when you port from python2 to python3
unable to reproduce problem on repl:
can you share you repl?
Codecademy isn’t designed to work as a shell for projects like this so you’re going to run into errors of this kind quite often. You should switch to your own dev environment or use something like repl, as Stetim suggests.
So if I were to use a Python 2 shell, then the raw_input() would work? Also, if I were to use input(), would the outcome still be the same? I remember when I started learning Codecademy, (using the Pyglatin course), I was able to recreate this same exact calculator using that shell. I switched it from Pyglatin to the first lesson and it suddenly didn’t work. (FYI this was around 2 years ago. I am recreating this for a friend of mine who is learning Python. He wants to see some actual code so he can study with it) When I accessed repl.it right now, I went in and inputted my code and it suddenly wanted parentheses around my print statements. When I accessed it before this was posted, it did say EOFError. I will screenshot.
(Also, is Codecademy using Python 2 or Python 3? I remember learning as Python 2, but I am not so sure now)
your code is clearly python2 (print statements) while in python3 print are function calls.
the python course is python2, however data science path course is python3
If i where you, i would do the following:
decide what python version you want to use for your project
understanding the core differences between the 2 major python versions and make changes if necessary
Ok. Thanks so much stetim94 and oduffy! I will try and change it.
(Does repl.it run on Python 3? [considering it is asking for parentheses around my print statements])
repl offers both, which you use is op to you. But what repl offers shouldn’t be the determining factor in deciding on python version, in fact it shouldn’t be a factor at all