Try It! range(1,11) not printing results


#1



https://www.codecademy.com/courses/python-beginner-en-KAgt5/3/3?curriculum_id=4f89dab3d788890003000096

Oops, try again. It looks like you didn't print the correctly filtered list to the console.
When I type the range(1,10), (1,12), (1,9) the program gives out the correct results. But when I use the range(1, 11), it gives the following error message. I don't know whether it's a system issue or if I am doing something wrong.

print the result of [1, 4, 9, 16, 25, 36, 49, 64, 81, 100].

squares = [x **2 for x in range(1,11)]
filter(lambda x: 30 <= x <=70, squares)Replace this line with your code.


#2

There's no print statement in the code you posted


#3

squares = [x **2 for x in range(1,12)]
filter(lambda x: 30 <= x <=70, squares)

I actually don't need to print but I just need to get the correct result. The above code give the following results:
"Oops, try again. It looks like your list consists of [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121] instead of [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]."

When I use the range of (1,10), it gives the following result:
squares = [x **2 for x in range(1,10)]
filter(lambda x: 30 <= x <=70, squares)

result: Oops, try again. It looks like your list consists of [1, 4, 9, 16, 25, 36, 49, 64, 81] instead of [1, 4, 9, 16, 25, 36, 49, 64, 81, 100].

The correct range should be (1,11) but it is not working. Giving the error message.


#4

If it should be 11, why do you use 10 and 12

It mentions printing, yet your code has no print statement, like mentioned before


#5

You are right the correct range is (1,11) but it is giving an error message. I tried the same codes for the range of 10, 12 to see if the codes are correct. 10 and 12 are working with exact same codes but when I change it to 11, it is not working. Strange!!!


#6

I'm not going to make the same suggestion a third time. See previous responses


#7

Thank you. I put the print statement in front of filter and it worked. I should have read the error message "It looks like you didn't print the correctly filtered list to the console" with more attention. Anyway, thank you once again for your time.


#8

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