BaaBaaGoof
0
Q:

how to capitalize first letter in python

msg = "good night"
print(msg.capitalize())
#output: Good night
14
 "hello world".title()
'Hello World'
>>> u"hello world".title()
u'Hello World'
4
# To capitalize the first letter in a word or each word in a sentence use .title()
name = tejas naik
print(name.title())    # output = Tejas Naik
2
str.capitalize() # This is will capitalize your string
7
    singers = ['johnny rotten', 'eddie vedder', 'kurt kobain', 'chris cornell', 'micheal phillip jagger']
    singers = [singer.capitalize() for singer in singers]
    print(singers)

   #instead of capitalize use title() to have each word start with capital letter
0

New to Communities?

Join the community