A string is a collection of characters which are enclosed in quotes.
Sometimes there is a need to find the number of characters in a string.
Use len() to find the number of characters in a string
This function gives the number of characters including spaces
Code : Accept input from keyboard and display number of characters in a string
Use input() to accept data from keyboard
str = input('Enter a string: ')
Create a variable and assign the result obtain by using len()
l = len(str)
Now the display the value of variable which contains count for a number of characters in a string
print(l)
Output
Enter a string: Python
6
Complete Code
str = input('Enter a string: ')
l = len(str)
print(l)