I’m indifferent

Syntax error in "Python Dictionaries" (Page 4) of "Beginning Python for Bioinformatics"

In "Python Dictionaries" (Page 4) of "Beginning Python for Bioinformatics" either the Python Interpreter is designed wrong or your example is at:

String slicing is similar to string indexing. Instead of retrieving a single character, string slicing allows us to retrieve sections of characters from a starting position up to, but not including, an ending position. The syntax is s[i:j], where i is the starting position and j is the ending position. So s[0:3] returns a string containing the characters in index positions 0, 1, and 2.

>>> s = 'CCGGAAGAGCTTACTTAG'
>>> s[0:3]
'CCG'
>>> s[3:6]
'GAA'
>>> s[6:9]
'GAG'
>>> s[9:12]
'CTT'

If i is the starting position and j is the ending position then specifying s[0:3] yields index positions 0, 1, 2, 3 not 0, 1, 2; likewise with s[3:6] s[6:9] s[9:12]. Relative to starting postion zero (0), index position 12 could not exist since 0-11 represents 12 positions.
2 people have
this question
+1
Reply