Remove list comprehension

Remove list comprehension, use list constructor instead
This commit is contained in:
Havan Agrawal
2019-08-23 00:23:18 -07:00
committed by GitHub
parent fc2b0c7558
commit 69babf96a8

View File

@ -5,13 +5,13 @@ tags: list,beginner
Initializes a list containing the numbers in the specified range where `start` and `end` are inclusive with their common difference `step`.
Use list comprehension and `range()` to generate a list of the appropriate length, filled with the desired values in the given range.
Use `list` and `range()` to generate a list of the appropriate length, filled with the desired values in the given range.
Omit `start` to use the default value of `0`.
Omit `step` to use the default value of `1`.
```py
def initialize_list_with_range(end, start = 0, step = 1):
return [x for x in range(start, end + 1, step)]
return list(range(start, end + 1, step))
```
```py