count a string length in python
Code snippet on how to count a string length in python
str = "Hello World!"
length = len(str)
This code example uses the len() function in Python to count the length of a string. The first line assigns the value “Hello World!“to a string variable called “str”. The second line uses the len() function to assign the length of the string (12 in this case) to the “length” variable. This code will output the integer “12” to the console, which is the length of the string “Hello World!”