Python では、文字列の長さをどのように判断しますか?
len()関数を使用して、文字列の長さを判断することができます。例を示します:
string = "Hello, World!"
length = len(string)
print("The length of the string is:", length)
結果は次の通りです:
The length of the string is: 13
len()関数を使用して、文字列の長さを判断することができます。例を示します:
string = "Hello, World!"
length = len(string)
print("The length of the string is:", length)
結果は次の通りです:
The length of the string is: 13