Python String islower ()

Il metodo islower () restituisce True se tutti gli alfabeti in una stringa sono alfabeti minuscoli. Se la stringa contiene almeno un alfabeto maiuscolo, restituisce False.

La sintassi di islower()è:

 string.islower ()

parametri islower ()

Il islower()metodo non accetta parametri.

Valore restituito da islower ()

Il islower()metodo restituisce:

  • Vero se tutti gli alfabeti che esistono nella stringa sono alfabeti minuscoli.
  • Falso se la stringa contiene almeno un alfabeto maiuscolo.

Esempio 1: valore restituito da islower ()

 s = 'this is good' print(s.islower()) s = 'th!s is a1so g00d' print(s.islower()) s = 'this is Not good' print(s.islower())

Produzione

 Vero Vero Falso 

Esempio 2: come utilizzare islower () in un programma?

 s = 'this is good' if s.islower() == True: print('Does not contain uppercase letter.') else: print('Contains uppercase letter.') s = 'this is Good' if s.islower() == True: print('Does not contain uppercase letter.') else: print('Contains uppercase letter.')

Produzione

Non contiene lettere maiuscole. Contiene lettere maiuscole.

Articoli interessanti...