In case you wish to use filter, map etc. and get a list in python 3, you have two techniques at your disposal, namely:
- Wrap the iterator around list( )
- Use list comprehensions instead
Wrapping the iterator around list
The following snippets returns all even numbers upto but not including 10.Using list comprehension technique
We can modify the above program to do the same task but using more familiar list comprehension method.This also gives us all even number upto but not including 10.
Leave a comment explaining how there two coding styles differ in efficiency and readability?