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
  • 1,048,767
  • 296
  • 4,058
  • 3,343

0 Answers0