Answers for "count number characters in a given string python"

10

count characters in string python

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

python count characters

# Basic syntax:
import re
len(re.findall('[characters]', your_string))

# Example usage:
# say you want to count all G, g, C, or c characters in the following DNA seq
len(re.findall('[GgCc]', "ACGTGCAcgattcgatCGCTAGCTAG"))
--> 14
Posted by: Guest on April-21-2022

Code answers related to "count number characters in a given string python"

Python Answers by Framework

Browse Popular Code Answers by Language