String indexing: from front or end : String Index « String « Python






String indexing: from front or end

String indexing: from front or end
 

S = 'spam'
print S[0], S[-2]               # indexing from front or end


           
         
  








Related examples in the same category

1.String indexing: Random AccessString indexing: Random Access
2.An index that is too large is replaced by the string size
3.Indices may be negative numbers, to start counting from the right. For example: