Description
Trick question. There’s nothing wrong with the code above, BUT there’s a better way to achieve the same result with a list comprehension: List comprehensions are great because they require less lines…
Summary
- Introduction Suppose I wanted to create a list of numbers from 1 to 1000 and wrote the following code… Can you figure out what’s wrong with it?
- numbers.append(i) Trick question.
- That’s why I’m presenting you with eight practice problems for you to drill this concept into your head!
- nums = [i for i in range(1,1001)]string = "Practice Problems to Drill List Comprehension in Your Head."