Use indexes
You slice a list that returns lists. Here you should use indexes instead:
firstDigit = x[0] lastDigit = x[-1]
Why the wrong choice for you:
When you execute x[0:1] , you take a list of items from the beginning of the list to the first interval.
item0, item1, item2, item3 ^ interval 0 ^ interval 1 ^ interval 2 ^ interval 3
Executing x[0:2] , for example, will return elements 0 and 1.
Thomas Orozco
source share