Blogging with TN
Saturday, 23 November 2013
Count occurence of character in a string
String = syzygy
I am interested in how many times letter "y" occurs in the string.
Just write this in Python Shell:
>>> str.count('syzygy', 'y') 3
or
>>> 'syzygy'.count('y') 3
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment