+ 2
What is the difference?
What is the difference between capitalize and title? It seems they do the same thing. Try this code? mystring = '4sDgg5' print(mystring.capitalize()) print(mystring.title())
2 Respostas
+ 5
Title will capitalize the first letter of every word in the string,
Capitalize will capitalize the first letter of the first word of a string.
ie, x 'hello world'
x.title() = Hello World
x.capitalize() = Hello world
+ 1
Try using both .capitalize() & .title() for space-separated strings, you will notice the difference.