+ 3

re.findall() vs str.count()

Could you please tell me whats the advantages/disadvantages of these methods which seem to give similar results.

23rd Dec 2019, 6:48 PM
Š•Š³Š¾Ń€ Š³Š¾Ń€Š“ŠµŠµŠ²
Š•Š³Š¾Ń€ Š³Š¾Ń€Š“ŠµŠµŠ² - avatar
2 Answers
+ 4
str.count() counts the instances of a certain string while re.findall() returns all matches. Might seem silly and useless but is helpful when you're doing RegEx matches.
24th Dec 2019, 12:34 AM
šŸ‘‘ Prometheus šŸ‡øšŸ‡¬
šŸ‘‘ Prometheus šŸ‡øšŸ‡¬ - avatar
+ 3
Thank you, friend!
23rd Dec 2019, 9:24 PM
Š•Š³Š¾Ń€ Š³Š¾Ń€Š“ŠµŠµŠ²
Š•Š³Š¾Ń€ Š³Š¾Ń€Š“ŠµŠµŠ² - avatar