Posts

Showing posts with the label Python Strings

Python Dictionaries and Strings

Strings: Group of characters Manupulation Methods: 1) capitalize:                     str.capitalize() 2) Count str.count(sub, start= 0,end=len(string)) str=”anjianjianji123” str.count(“anj”) 3)Find str.find(str, beg=0, end=len(string)) str1 = "this is string example....wow!!!"; str2 = "exam"; print str1.find(str2) print str1.find(str2, 10-----beg,100-----end) print str1.find(str2, 40) 4)Index str.index(str, beg=0 end=len(string)) 5)   Len len( str ) str = "this is my name"; print "Length of the string: ", len(str) 6)Split: str.split(str="", num=string.count(str)).   str1 = "this is string example....wow!!!"; print str1.split("exam") ['this is string ', 'ple....wow!!!'] 7) isalnum str = "this2009"; print str.isalnum() str = "this is string example....wow!!!"; print str.isalnum() Returns Boolean Val...