October 2006
Intermediate to advanced
888 pages
16h 55m
English
The count method counts the number of occurrences of any of a set of specified characters:
s1 = "abracadabra"
a = s1.count("c") # 1
b = s1.count("bdr") # 5The string parameter is like a simple regular expression. If it starts with a caret, the list is negated:
c = s1.count("^a") # 6
d = s1.count("^bdr") # 6A hyphen indicates a range of characters:
e = s1.count("a-d") # 9
f = s1.count("^a-d") # 2Read now
Unlock full access