Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # str_better_than_title_and_capwords.py
- s = "they're anna-maurie's friends from the x.y.z. in UK"
- print s.title() #
- import string
- print string.capwords(s)
- def titlefn(s):
- sss=['']
- for i in list(s):
- if sss[-1] == '': i=i.upper()
- sss[-1]+=i
- if i in '- .':
- sss.append('')
- return ''.join(sss)
- print titlefn(s)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement