len()
function :# Return the length of a string
my_string = "Hello, World!"
string_length = len(my_string)
print("The length of the string is:", string_length)
The length of the string is: 13
Hello, World!
"` to the variable `my_string
`. We then use the `len()
` function to get the length of `my_string
`, and assign the result to the variable `string_length
`.print()
` function to print the message "The length of the string is:" followed by the value of `string_length
`.len()
` function returns.