Question 16
The following Python expression is entered into a fresh Python shell with no prior import statements. Determine the result from evaluating the following expression. [3 marks]
Solution
The list [i for i in range(1, 10, 2)] contains integer elements starting from 1 and all integers 2 steps apart from each other, i.e., [1, 3, 5, 7, 9].
When placed with string index operator [::-1], it effectively reverses the order of this list, making it [9, 7, 5, 3, 1].
Right here, the element in the second index is 5.