Why I'm getting this print error?

I can’t understand why I’m having this error. Can someone help me out?

https://www.codecademy.com/paths/computer-science/tracks/cspath-flow-data-iteration/modules/dspath-python-loops/lessons/learn-python-loops/exercises/list-comprehension

in a for loop the common structure is:

for this in this:
    do this 

not:

this for this in this:
    do this

it might possible but as far as I know it’s not if it is what you are asked to do than let me know and I’ll check it out

I’m doing an exercise about “List Comprehensions”, so that’s why I used this structure. It’s strange that I’m getting this error, because it is actually printing out the result.

maybe you should try return() instead of print()

Nop! Didn’t work. Look at the questions

Why would #1 be right and #2 be wrong?

codecademy loves to test one thing and then say something else. they don’t care in the slightest what you’re printing, they care about the formatting in your use of print

I can’t pass by! :confused:

Really don’t know what to do

I just tested something different and it worked.

I deleted a space between “print” and (… it worked…strange!

It’s just Codecademy using pattern matching to check your code, which is quite often not a good way to perform testing of the meaning of code. The following two statements mean the same thing to the Python interpreter:

print(can_ride_coaster)
print (can_ride_coaster)

If one passes Codecademy’s submission correctness test (SCT), so should the other, but Codecademy’s SCT for this exercise does not like that intervening space.

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