Exercise: List Comprehension II

Here, we use list comprehension to extract the first character of each name in the names list. However, there's a small mistake. Fix the code to get the correct output.
names = ["Alice", "Bob", "Charlie", "David"]
### adjust code here ### first_characters = [name[0] for x in names]
print(first_characters) # expected ['A', 'B', 'C', 'D']
Python
Setting up Python environment...
Output