La función title() en python es el método de string de Python que se utiliza para convertir el primer carácter de cada palabra a mayúsculas y los caracteres restantes a minúsculas en la string y devuelve una nueva string.
Sintaxis:
str.title() parameters:str is a valid string which we need to convert. return: This function returns a string which has first letter in each word is uppercase and all remaining letters are lowercase.
Python
# Python title() Method Example str1 = 'geeKs foR geEks' str2 = str1.title() print 'First Output after Title() method is = ', str2 # observe the original string print 'Converted String is = ', str1.title() print 'Original String is = ', str1 # Performing title() function directly str3 = 'ASIPU pawan kuMAr'.title() print 'Second Output after Title() method is = ', str3 str4 = 'stutya kUMari sHAW'.title() print 'Third Output after Title() method is = ', str4 str5 = '6041'.title() print 'Fourth Output after Title() method is = ', str5
Producción:
First Output after title() method is = Geeks For Geeks Converted String is = Geeks For Geeks Original String is = geeKs foR geEks Second Output after title() method is = Asipu Pawan Kumar Third Output after title() method is = Stutya Kumari Shaw Fourth Output after title() method is = 6041
Publicación traducida automáticamente
Artículo escrito por pawan_asipu y traducido por Barcelona Geeks. The original can be accessed here. Licence: CCBY-SA