Python String istitle ()

O istitle () retorna True se a string for uma string com capa de título. Caso contrário, retorna False.

A sintaxe do istitle()método é:

 string.istitle ()

Parâmetros istitle ()

O istitle()método não leva nenhum parâmetro.

Valor de retorno de istitle ()

O istitle()método retorna:

  • True se a corda é uma corda com caixa de título
  • False se a string não for uma string com capa de título ou uma string vazia

Exemplo 1: Trabalho de istitle ()

 s = 'Python Is Good.' print(s.istitle()) s = 'Python is good' print(s.istitle()) s = 'This Is @ Symbol.' print(s.istitle()) s = '99 Is A Number' print(s.istitle()) s = 'PYTHON' print(s.istitle())

Resultado

 Verdadeiro Falso Verdadeiro Verdadeiro Falso

Exemplo 2: Como usar istitle ()?

 s = 'I Love Python.' if s.istitle() == True: print('Titlecased String') else: print('Not a Titlecased String') s = 'PYthon' if s.istitle() == True: print('Titlecased String') else: print('Not a Titlecased String')

Resultado

 String com capa de título Não é uma string com capa de título

Artigos interessantes...