0

I have the following piece of code :

str1 = "abcd"
print(str1[1:9:3])

The answer I get is "b"

How is this being calculated. This means that in the string str1, print out the 3rd character from 1st position to 9th. Hence str1[1:9] will be "bcd". And the third character in this should throw me an error. But instead I am getting "b". How is this ?

Martijn Pieters
  • 963,270
  • 265
  • 3,804
  • 3,187

0 Answers0