Lists and For Loop
Exercise #3 & 4.

I coded both using differently and they were both accepted. They both have a different output. Not sure which one is correct.
Here are my codes:

squares = [i**2 for i in single_digits]

square =
for i in single_digits:

When you ask a question, don’t forget to include a link to the exercise or project you’re dealing with!

If you want to have the best chances of getting a useful answer quickly, make sure you follow our guidelines about how to ask a good question. That way you’ll be helping everyone – helping people to answer your question and helping others who are stuck to find the question and answer! :slight_smile:

Hello @coursesurfer26754, I’m not sure what you’re getting, but when I use a for loop and a list comprehension, they both return the same results:

It could be that the exercise asked you to create a list cubes which takes every element in single_digits and cubes it?
Also, you might want to check your spelling:

Here you have square*s* and square.

Here you have square and square*s*.
I hope this has helped!

1 Like

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