Why does this code not work:

```
squares = [x ** 2 for x in range(1, 11)]
print filter(lambda x: squares[29:70], squares)
```

Also, please explain the syntax for the lambda (:

Why does this code not work:

```
squares = [x ** 2 for x in range(1, 11)]
print filter(lambda x: squares[29:70], squares)
```

Also, please explain the syntax for the lambda (:

You are supposed to print out the values in squares between 30 and 70, but you try to slice the list to print out the values with indexes between 30 and 70. Use <= to select the values from squares.

If you really wanted to print out the squares from index 30 to 70 you would also have to use `x in squares[30:70]`

, because the lambda selects all x that make the statement behind the colon true.

2 Likes

Ah, I see, thanks for the quick answer

1 Like

squares = [x ** 2 for x in range(1,11)]

print filter(lambda x: x >= 30 and x <= 70 , squares)

this is my answer.

1 Like

I have that exact code and doesnāt workā¦ ?

```
squares=[x**2 for x in range(1,11)]
y=x**2
print filter(lambda y: y>=30 and y <=70, squares)
```

I had to use another variable for x**2, because I canāt just use (lambda x**2ā¦ : and if I donāt use square, I get the results of x, not x**2. If thereās a shorter way to do it, Iāll be happy to learn.

2 Likes

despair186 - my code is below. You donāt need to use x**2 (or a variable set to it) in the lambda part. I think the x**2 is just used to populate the list. If you imagine the numbers in the list as digits, rather than the calculation, it helps separate the two in your mind.

i believe your āy=x**2ā is just ignored by the rest of the code. You could use any name for the lambda variable be it x, y or anything else.

squares = [x**2 for x in range(1,11)]

print filter(lambda x: x >= 30 and x <= 70, squares)

1 Like

spacecamel100,

I came up with the exact same code on my own (surprisingly, maybe some of this is beginning to stick.) It worked flawlessly to my surprise.

1 Like

Iām stuck. Iām using this code and it doesnāt work. I keep getting a āSCT Error.ā In addition, it seems like thereās no way to advance in lessons, which completely kills my experience. Can anyone help please?

squares = [x ** 2 for x in range(1,11)]

print filter (lambda x: x >= 30 and x <= 70 , squares)

2 Likes

same issue here. I keep getting the āSCT errorā, but its still printing the values in the list that its supposed to

3 Likes

same here, really frustrating.

Tried using another browser and deleting cookies. Nothing helps.

I reported it as a bug , hopefully itāll get sorted out soon

1 Like

Hi,

i am also facing same issue and reported as bug, can you pls tell me how much time it will take to sort out

I keep getting SCT Error as well

same here with this code:

```
squares = [x ** 2 for x in range(1,11)]
print squares
print filter (lambda x: x >= 30 and x <= 70, squares)
```

(I use the āprintā just to check the results)

NEED HELP:

Below is the code that I use, but I always end up getting an SCT error.

squares = [x ** 2 for x in range(1,11)]

print filter (lambda x: x >= 30 and x <= 70 , squares)

Does anyone have have a solution that works?

did you get an answer for this problem?

I am stuck on the same issue.

The same problem even when I click Run without code.

It didnāt work yesterday (as Iāve written above) but just now it worked so if it was indeed a problem on their end, thank you guys for the bug reports and I hope it works for you too if you try again.