Created
September 21, 2016 06:25
-
-
Save pinkpretty/48c8e0a700017c54d3352ca12d4117f5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
this is practicepython exercise - 7 | |
''' | |
''' | |
Let’s say I give you a list saved in a variable: a = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]. | |
Write one line of Python that takes this list a and makes a new list that has only the even elements of this list in it. | |
''' | |
import random | |
list =[random.randrange(1,101) for i in range(10)] | |
print(list) | |
even = [item for item in list if(item%2 == 0)] | |
print(even) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment