Python 文字列 最大・最小文字の取得方法【サンプルコード付】

Pythonの組み込み関数であるmax()とmin()を使用して、文字列内で最大および最小の文字を取得することができます。

text = "hello"
max_char = max(text)
min_char = min(text)

print("最大字符:", max_char)
print("最小字符:", min_char)

このコードは出力します:

最大字符: o
最小字符: e
bannerAds