xxxxxxxxxx
import camelcase
c = camelcase.CamelCase()
txt = "Welcome Dear ismail "
print(c.hump(txt))
xxxxxxxxxx
my_string = "programiz is Lit"
cap_string = my_string.capitalize()
print(cap_string)
xxxxxxxxxx
>>> "hello world".title()
'Hello World'
>>> u"hello world".title()
u'Hello World'
xxxxxxxxxx
# 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
xxxxxxxxxx
my_string = "programiz is Lit"
print(my_string[0].upper() + my_string[1:])
xxxxxxxxxx
string = "hello world"
capitalized = string[0].upper() + string[1:]
print(capitalized)
xxxxxxxxxx
const str = 'i have learned something new today';
const arr = str.split(" ");
for (let i = 0; i < arr.length; i++) {
arr[i] = arr[i].charAt(0).toUpperCase() + arr[i].slice(1);
}
const str2 = arr.join(" ");
console.log(str2); //Outptut: I Have Learned Something New Today
xxxxxxxxxx
"hello world".title()
'Hello World'
>>> u"hello world".title()
u'Hello World'
xxxxxxxxxx
# Use title() to capitalize the first letter of each word in a string.
name = "elon musk"
print(name.title())
# Elon Musk