mystr="Sri Lanka" print( len(mystr) ) print( mystr.upper() ) print( mystr.lower() ) print( mystr[1]) print( mystr[-1]) mylist = [10, "Ajith", 67.3, 78.2] print(mylist) print( mylist[0] ) print( mylist[3] ) print( mylist[-1] ) print( mylist[-2] ) sublist=mylist[1:3] print (sublist) sublist=mylist[1:] print (sublist) print(sublist) mylist.append("Java") mylist.append(1988) print(mylist) #otherlist=[2,5,1,5,6] otherlist=["Pineapple","Apple","Mango","Banana","Acorn Squash","Coconut","Apricot"] print(otherlist) otherlist.reverse() print(otherlist) otherlist.sort() print(otherlist)Result
Wednesday, January 18, 2012
Python Note 2 (String manipulations)
Code
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment