str.count algorithm

H

Hellnar

Hello,
I am trying to find what algorithm Python uses for the built-in
str.count function, if it has a name.

Thanks
 
R

Raymond Hettinger

Hello,
I am trying to find what algorithm Python uses for the built-in
str.count function, if it has a name.

Roughly the same as:

sum(1 for c in s if c == tgt)


Raymond
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Clarification of notation 2
Encryption algorithm 1
str.count is slow 3
Algorithm 1
Quick sort algorithm 1
Variable Sequence Problem 2
Math python question 10
Who are low code solutions designed for? 1

Members online

Forum statistics

Threads
474,173
Messages
2,570,938
Members
47,482
Latest member
solbuggy09

Latest Threads

Top