×
Write the following Python code to do the following (complete ALL of these using list comprehension).
[1,2,3,4]
, print out all the values in the list.[1,2,3,4]
, print out all the values in the list multiplied by 20.["Elie", "Tim", "Matt"]
, return a new list with only the first letter (["E", "T", "M"]
).[1,2,3,4,5,6]
return a new list of all the even values ([2,4,6]
).[1,2,3,4]
and [3,4,5,6]
, return a new list that is the intersection of the two ([3,4]
).["Elie", "Tim", "Matt"]
return a new list with each word reversed and in lower case (['eile', 'mit', 'ttam']
).["i", "r", "t"]
).[12, 24, 36, 48, 60, 72, 84, 96]
).['m', 'z', 'n', 'g']
).[[0, 1, 2], [0, 1, 2], [0, 1, 2]]
.Generate a list with the value:
[ [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] ]
For solutions to these exercises, click here.
When you're ready, move on to Dictionary Basics