I'm having difficulty turning tuple into indexing in order to output a new list.
(I just don't mind the Python code format here, I'm sorry)
For example, the input list is [0, 3, 4, 2, 1, 5]
and the input tuple is (0,2)
I wanna get the list of index 0 to index 2 of the input list, I mean my expected output is [0, 3, 4]
. Does anyone know how to convert the tuple (0,2)
into a continuous indexing to get the expected output?
Here's my way to complete that:
final_list = [input_list[i] for i in input_tuple]
I knew my way to do it is wrong, I couldn't think up another way to do it. Could you guys help me out?