Advertisement
here2share

# str_better_than_title_and_capwords.py

Sep 6th, 2015
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.33 KB | None | 0 0
  1. # str_better_than_title_and_capwords.py
  2.  
  3. s = "they're anna-maurie's friends from the x.y.z. in UK"
  4.  
  5. print s.title() #
  6.  
  7. import string
  8. print string.capwords(s)
  9.  
  10. def titlefn(s):
  11.     sss=['']
  12.     for i in list(s):
  13.         if sss[-1] == '': i=i.upper()
  14.         sss[-1]+=i
  15.         if i in '- .':
  16.             sss.append('')
  17.     return ''.join(sss)
  18. print titlefn(s)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement