English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Verifica se todos os nomes das palavras da string estão em maiúsculas e as outras em minúsculas. Se estiverem, o istitle() retorna True. Caso contrário, retorna False.
A sintaxe do método istitle() é:
string.istitle()
O método istitle() não leva nenhum parâmetro.
Retorno do método istitle():
Se todos os nomes das palavras da string estiverem em maiúsculas e as outras em minúsculas, retorna True, caso contrário, retorna False.
s = 'Python É Bom.' print(s.istitle()) s = 'Python é bom' print(s.istitle()) s = 'This Is @ Symbol.' print(s.istitle()) s = ''99 É um Número print(s.istitle()) s = 'PYTHON' print(s.istitle())
Quando você executar o programa, a saída será:
Verdadeiro Falso Verdadeiro Verdadeiro Falso
s = 'I Love Python.' if s.istitle() == True: print('istitle() é verdadeiro') else: print('istitle() é falso') s = 'PYthon' if s.istitle() == True: print('istitle() é verdadeiro') else: print('istitle() é falso')
Quando você executar o programa, a saída será:
istitle() é verdadeiro istitle() é falso