The Python implementation capitalizes the first letter of a string and lowercase the rest

  • 2021-06-28 09:25:47
  • OfStack

By using the map() function, the non-standard English names entered by the user are capitalized and the standard names in other lower cases are changed.

Idea: Use the capitalize() function to uppercase the first letter of a string and lower case the rest


L1 = ['AdmIn','anny','LUCY','sandY','wILl']
def normallize(name):
 return name.capitalize()
L2 = list(map(normallize,L1))
print(L2)

Print as follows:


['Admin', 'Anny', 'Lucy', 'Sandy', 'Will']

Related articles: