Answers for "check total no of characters in a string using python"

10

count characters in string python

>>> sentence = 'Mary had a little lamb'
>>> sentence.count('a')
4
Posted by: Guest on December-30-2020
0

string acharacters count in python without using len

# User inputs the string and it gets stored in variable str
str = input("Enter a string: ")

# counter variable to count the character in a string
counter = 0
for s in str:
      counter = counter+1
print("Length of the input string is:", counter)
Posted by: Guest on November-14-2020

Code answers related to "check total no of characters in a string using python"

Python Answers by Framework

Browse Popular Code Answers by Language