0
Why is the output c and d
i expect the putput to be c and e. x = ("a", "b", "c", "d", "e") print x[2:4]
2 Answers
+ 2
because computers start counting from zero(0) so x[2:4] means start at 2 all the way to 4 but NOT including 4.
"a" at index [0]
"b" at index [1]
"c" at index [2]------> start
"d" at index [3]-----> middle
"e" at index[4]------> end (not including index 4)
To print c to d you need to do :
print(x[2:5]
+ 1
crystal clear thank you