Exercise: List Comprehension I
Here, we use list comprehension to double the integers in the
numbers
list. However, there's something missing. Fix the code to get the correct output. Hint: The mistake is in the expression part of the list comprehension. Remember the syntax: [expression for item in iterable]
.numbers = [10, 20, 30, 40, 50]
### adjust code here ###
doubled_numbers = [num for num in numbers]
print(doubled_numbers) # expected [20, 40, 60, 80, 100]
Python
Setting up Python environment...
Output