Problem

3/7

Nested tuples. Referencing elements

Theory Click to read/hide

Referring to elements. Nested Tuples
Tuples can contain other tuples as elements. Also, lists, strings, etc. can be used as elements of a tuple.
Accessing elements is similar to accessing elements of a list, specifying the index of the element in square brackets. Indexing starts from zero.
When referring to nested elements, additional square brackets must be used.
  my_tuple = (('a', 'b', 'c'), [1, 2], ((1, 'a' ), ('b', 'c'))) print(my_tuple[2][1])    # ('b', 'c')

Problem

The input of the program is 6 lines:
1) string s;
2) one-dimensional array a
3) a set of integers b (separated by a space);
4) a set of integers c (separated by a space);
5) number n - 0, 1, 2 - element index of my_tuple tuple (see below);
6) number k - the index of the nested element of the tuple.

Create a tuple from the original data in the form my_tuple(s, a, (b, c)).
The created tuple is displayed on the screen (this line is already written in the program, you do not need to write it).

Write a program fragment that, given the numbers n, k  outputs the corresponding element of the my_tuple.
tuple It is guaranteed that n and k lie within the required bounds.

 

Examples
# Input Output
1 hello
1 2 3 4 5
6 7 8 9 0
2 1 3 4 5
2
1
('hello', [1, 2, 3, 4, 5], ((6, 7, 8, 9, 0), (2, 1, 3, 4, 5)) )
(2, 1, 3, 4, 5)