Python interpreter? :/


Please leave the following link in the post so we can find the unit module, else replace it with a link to the exact lesson:

Strings and Console Output

This code:

pi = 3.14
print str(pi)

Is suposed to print the integer 3.14 in console. In codecademy does, but in my IDLE of Python 3.6.2 does not. Can anyone explain me…? Please :slight_smile:


Have you ensured your python version is the same as codecademy? If it isn’t, you can’t just go copy pasting code and expect it to work


But I don’t know what is the version of codecademy Python. Which is it?


have you googled: find python version or something similair? If you do, you find this:

which yields us code:

import sys

we can use to find the python version, surely this will run in a lesson to find codecademy’s python version


Yes, I’m using Python 3.6.2. I used:

import sys

in codecademy so it said the version is 2.7.12, so now it’s understandable.
Anyways, Python 2 is not the same as Python 3. There is no course for Python 3?


not the same i wouldn’t say, but at the release of python3 the decision was made to make python3 not backward-compatible with python2. So yes, there are differences, but they still are the same language

if we google:

python2 vs python3 differences

we find this article:

like i was trying to show you already in previous answer, there is a lot you can find by googling


Okey, thanks for everything, I should google the things next time :slight_smile:


Of course we are here on the forum to help, but being capable of a simple google search is a must for a developer. And never take for granted that two environments are the same.


You should use python3.

Not to defend codecademy, but most of the differences between 2 and 3 aren’t brought up in the course. Whenever something doesn’t “work”, you ought to be googling for how to do that something. This will probably just be print statement vs function and that division always produces a float in python3

Another thing is that codecademy uses an old way of formatting strings (with the modulo operator) - in newer code you should be using str.format or in 3.6 and later prefix with an f instead:

name = 'bob'

# old:
'hello %s' % name
# new:
'hello {}'.format(name)
# 3.6+
f'hello {name}'


@ionatan makes a valid point, for new projects always use python3 if possible


I’ve already seen that most fo the differences are of the kind:


pi = 3.14
print str(pi)

-> 3.14


pi = 3.14
print (str(pi))

-> 3.14

So is not that difficult.


well, some of the difference are more significant:

print range(5) # outputs: [0, 1, 2, 3, 4]

while in python3:


range produces a range object, so, there are some significant differences. raw_input() vs input(), also an important one.

Yet this changes might seem small, but in a large program, it might be difficult to oversee


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.