 |
 |
 |
Introduction to Python
(by Ilan Schnell)
|
Interactive (example) session:
>>> p='the five boxing wizards jump quickly'
>>> p
'the five boxing wizards jump quickly'
>>> len(p)
36
>>> len(set(p))
27
>>> p.count(' ')
5
>>> words = p.split()
>>> words
['the', 'five', 'boxing', 'wizards', 'jump', 'quickly']
>>> len(words)
6
>>> words[3]
'wizards'
>>> words[:3]
['the', 'five', 'boxing']
>>> '--'.join(words)
'the--five--boxing--wizards--jump--quickly'
>>> p.replace(' ','--')
'the--five--boxing--wizards--jump--quickly'
>>> p.find('wiz')
16
>>> p.find('fox')
-1