List comprehension issue in Saving Time and Memory

Hello again,
I’m going through the Learn Python Programming course and have arrived at the point where I need to output a list of consonants from the alphabet through list comprehension. I seem to have been able to do this based on the output but for some reason it is not triggering the first flag to check if I am using a \[.+for \w* in alphabet if.+\] piece of code. It seems that I am though. Here is my link:

Thanks for your guys’ hard work.

Hi @CameronKruger! Mind posing the code that you are using to try to pass this check, or updating your project to contain it? I just took a look at your project but it looks like you may have moved on to a new step.

If you’d like to do the latter, feel free to create a new file in your project with that code. Or you can just paste it here, whatever’s easier for you!

Hi again Saul,
My bad, I should have created a separate file. Here is my code:

_ = list # Do not remove this alias to list

alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
vowels = ['a','e','i','o','u']
output = (c for c in alphabet if c not in vowels)

I also created a new file in my project,

Hey @CameronKruger! Looks like you are creating a generator in output = (c for c in alphabet if c not in vowels). The first check is looking for the syntax to create list comprehensions i.e. using square brackets, rather than parentheses. Try output = [c for c in alphabet if c not in vowels].

Let me know if you have any other questions!

1 Like

Once again I :man_facepalming: at my attention to detail! Thank you Lorraine. You have solved my question.

1 Like