Skip to content

Question 9

Evaluate:

'mangosteen'[-5:-10] + ' juice'
Solution

Providing a range like [-5:-10] is effectively the same as [-5:-10:1], where the index count tries to increase from -5 to -10. However, since going from -5 to -10 is in a decreasing direction, 'mangosteen'[-5:-10] results in an empty string, i.e., ''. This is different from 'mangosteen'[-5:-10:-1], where you indicate a decrease in index count to 'sogna'.

Hence, 'mangosteen'[-5:-10] + ' juice' \(\Rightarrow\) '' + ' juice' \(\Rightarrow\) ' juice'

Answer
' juice'