To put it simply, my input is:
capitalize_me = ['an abacus','bitter beefsteak','comfy culottes']
for i in capitalize_me:
print(i.capitalize(), end=',')
and my output is: An abacus,Bitter beefsteak,Comfy culottes,
But I need: [An abacus,Bitter beefsteak,Comfy culottes,]
with the brackets. what am I doing wrong?
You never stored the converted strings back into a list.
capitalize_me = ['an abacus','bitter beefsteak','comfy culottes']
done = [phrase.capitalize() for phrase in capitalize_me ]
print(done)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.