Metodo Python String max ()

Descrizione

Metodo delle stringhe Python max()restituisce il numero massimo di caratteri alfabetici dalla stringa str .

Sintassi

Di seguito è riportata la sintassi per max() metodo -

max(str)

Parametri

  • str - Questa è la stringa da cui deve essere restituito il massimo di caratteri alfabetici.

Valore di ritorno

Questo metodo restituisce il numero massimo di caratteri alfabetici dalla stringa str.

Esempio

L'esempio seguente mostra l'utilizzo del metodo max ().

#!/usr/bin/python

str = "this is really a string example....wow!!!";
print "Max character: " + max(str)

str = "this is a string example....wow!!!";
print "Max character: " + max(str)

Quando eseguiamo il programma sopra, produce il seguente risultato:

Max character: y
Max character: x