Mega Code Archive

 
Categories / Python Tutorial / String
 

Slice a string

pystr = 'Python' iscool = 'is cool!' print pystr[0] print pystr[2:5] print iscool[:2] print iscool[3:] print iscool[-1]