in many string munging and scripting applicationsbuilt-in string methods are sufficient as an examplea comma-separated string can be broken into pieces with splitin [ ]val ' ,bguidoin [ ]val split(','out[ ][' '' 'guido'split is often combined with strip to trim whitespace (including newlines)in [ ]pieces [ strip(for in val split(',')in [ ]pieces out[ ][' '' ''guido'these substrings could be concatenated together with two-colon delimiter using additionin [ ]firstsecondthird pieces in [ ]first '::second '::third out[ ]' :: ::guidobutthis isn' practical generic method faster and more pythonic way is to pass list or tuple to the join method on the string '::'in [ ]'::join(piecesout[ ]' :: ::guidoother methods are concerned with locating substrings using python' in keyword is the best way to detect substringthough index and find can also be usedin [ ]'guidoin val out[ ]true in [ ]val index(','out[ ] in [ ]val find(':'out[ ]- note the difference between find and index is that index raises an exception if the string isn' found (versus returning - )in [ ]val index(':'valueerror traceback (most recent call lastin (---- val index(':'valueerrorsubstring not found relatedlycount returns the number of occurrences of particular substringin [ ]val count(','out[ ] replace will substitute occurrences of one pattern for another this is commonly used to delete patternstooby passing an empty string data wranglingcleantransformmergereshape www it-ebooks info