Difference between revisions of "Coursera - Python Data Structures"
From MyWiki
(Created page with "'''String slicing :''' a[start:end] # items start through end-1<br> a[start:] # items start through the rest of the array<br> a[:end] # items from the beginning throug...") |
|||
Line 4: | Line 4: | ||
a[:end] # items from the beginning through end-1<br> | a[:end] # items from the beginning through end-1<br> | ||
a[:] # a copy of the whole array<br> | a[:] # a copy of the whole array<br> | ||
+ | |||
+ | '''String find''' <br> | ||
+ | <source lang="python"> | ||
+ | #!/usr/bin/python | ||
+ | |||
+ | str1 = "this is string example....wow!!!"; | ||
+ | str2 = "exam"; | ||
+ | |||
+ | print str1.find(str2) | ||
+ | print str1.find(str2, 10) | ||
+ | print str1.find(str2, 40) | ||
+ | </source> |
Latest revision as of 17:02, 19 November 2015
String slicing :
a[start:end] # items start through end-1
a[start:] # items start through the rest of the array
a[:end] # items from the beginning through end-1
a[:] # a copy of the whole array
String find
#!/usr/bin/python str1 = "this is string example....wow!!!"; str2 = "exam"; print str1.find(str2) print str1.find(str2, 10) print str1.find(str2, 40)