I’m trying to convert a list of strings to uppercase letters using the map
function in Python, but the output is unexpected. Here’s my code:
names = ["Alice", "Bob", "Charlie"]
uppercase_names = list(map(str.upper(), names)) # Using map with str.upper()
print(uppercase_names)
# Output: ['<function str.upper at 0x7f88329822b0>', '<function str.upper at 0x7f88329822b0>', '<function str.upper at 0x7f88329822b0>']
What am I doing wrong? I expected the output to be ["ALICE", "BOB", "CHARLIE"]
.
New contributor
Ronak is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1