The Python implementation capitalizes non standard English names

  • 2020-05-17 05:43:45
  • OfStack

For example,

Input: [' adam ', 'LISA', 'barT], output: [' Adam', 'Lisa', 'Bart'].

Method 1


def wgw(x): 
  return [x[0].upper(),x[1:].lower()] 
 
map(wgw,['adam','LISA','barT']) 

Method 2


def wgw1(x): 
  return x.capitalize() 
 
map(wgw1,['adam','LISA','barT']) 

Methods 3

map(lambda x:x.capitalize(),['adam','LISA','barT'])

conclusion

The above is the implementation of Python will not standardize the English first letter uppercase, other lowercase specification of the full content of the name, I hope the content of this article for everyone to learn or use python can be helpful, if you have questions you can leave a message to communicate.


Related articles: