Mega Code Archive

 
Categories / Python / String
 

Degenerate slice indices

#an index that is too large is replaced by the string size,  #an upper bound smaller than the lower bound returns an empty string. word = "Hello world" print word[1:100] print word[10:] print word[2:1]