Skip to content

Instantly share code, notes, and snippets.

@crazyrohila
Last active November 30, 2018 15:45
Show Gist options
  • Save crazyrohila/ea332aebefe9a87806648193e5d14805 to your computer and use it in GitHub Desktop.
Save crazyrohila/ea332aebefe9a87806648193e5d14805 to your computer and use it in GitHub Desktop.
Rich Capitalize
def caps(text):
words = text.split()
capswords = []
for word in words:
if ('<b>' in word):
wd = word.split('<b>')
word = wd[0].capitalize()+'<b>'+wd[1].capitalize()
elif ('</b>' in word):
wd = word.split('</b>')
word = wd[0].capitalize()+'</b>'+wd[1].capitalize()
else:
word = word.capitalize()
capswords.append(word)
print(' '.join(capswords))
return ' '.join(capswords)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment