What is wrong here with my code?



What is wrong here? I´m writing this exact program here (image) into my IDLE, but it wont work. I made the changes to suit python 3. For example the ( ) for the print function.

I´m a real newbie, and I´m not sure how I can test/run my code, to make it work like in the consol on codecademy…

Best regards



you might need to copy the code into the IDLE in two parts, first the function and then function call. IDLE works different from writing python scripts


Ok, thanks!

What can I use to write and test python code? Is Anaconda a good option?


given you have the IDLE installed, you also installed the python interpreter. Which means you can write python scripts with any text-editor and use the python interpreter to run those python scripts

After doing this, you can look at more advanced options like ipython and jupyter notebook



Many many thanks!


What do you mean by not working?
Similarly, what are you hoping anaconda would do for you? It’s a package distribution, not a text editor or python interpreter.

Typically you execute python code by writing it to a file and executing python with the filename as an argument. In your browser a text editor and the input/output of your program share the same page… That’s because it’s a website, they’re two very separate actions.

If you ever use something other than a text editor and python itself you better have a good reason for it, otherwise it’s better to cut out the number of things that can go wrong, to stay in control of what is going on. And then, when you know what’s going on with everything, and if you at that point have specific requirements that something satisfies, then you may want to introduce other tools.


Thanks for response, Ionatan!

Hmm, I think I get your point. As I wrote I´m a real newbie on this…

What do you mean with “executing python with the filename as an argument.” ?

I´ve mostly practised in codecademy and haven´t used it “for real” so to speak.

But I can see that is what I have to do now. To practise it outside the codecademy-millieu.

Thanks again


When you tell your operating system to spawn a process, you tell it the filename where the executable code exists, and then you might want to also provide some information to the program at startup, in python’s case the file with your python code.

So you’d open up your terminal app and type in something like

/usr/bin/python /home/wumama/hello.py
(except adjusted for where your python executable and python code is)

Typically it suffices to type only python (/usr/bin is likely in your PATH variable, which will be searched for what you typed), and typically you’d change directory to where your code is, leaving you with:

python hello.py

…ought to be the first thing anyone learns to do with a computer


Thanks for your support, Ionatan!

Do you have any suggested reading (online) for learning all this very basic


This video series maybe? “Basic knowledge” is a bit hard to pin down, it could take many directions.
I don’t really know what’s out there, but I think this is an excellent start.