Waz wrong? i can't use what i learnt here in real python 3


#1


The code is correct at class, but doesn't work in REAL Python 3. Waz wrong


n = [[1, 2, 3], [4, 5, 6, 7, 8, 9]]
# Add your function here
def flatten(lists):
    results=[]
    for numbers in lists:
        for i in numbers:
            results.append(i)
    return results
print flatten(n)


#2

As far as I know in python3 you need () around after your print keyword:

print(flatten(n))

The exercise here uses python2.7 afaik.


#3

Hi @dervish82 ,

@haxor789 is correct. Codecademy uses Python 2.7.

You can check what version you are using by doing this ...

import sys
print(sys.version)

Output on Codecademy ...

2.7.3 (default, Dec 18 2014, 19:10:20) 
[GCC 4.6.3]

Use parentheses when checking the version so that you do not get an error if it is version 3.x.


#4

Yes u r right, I tried this before but it didn't appear in my Python 3.4 version


#5

Yes u r right, I tried this before but it didn't appear in the Shell of my Python 3.4 version


#6

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