Problem B
Parse Integers
Write a function, list_to_int_tuple(search_list), that converts every element in a given list to an integer and then returns a tuple consisting of these integer elements.
If the function encounters elements that cannot be converted to integers, it ignores them.
The main file, which handles input and output, is already provided. - Please only submit your function definitions, without any code outside the functions!
Hint: Use try-except and the int() constructor.
Input
The function recieves one list
In the tests,
In the samples below, the first and only line of the input
contains the elements of the list
Output
The function should return one tuple
Sample Input 1 | Sample Output 1 |
---|---|
1,2,bla,42,52,62,t |
(1, 2, 42, 52, 62) |
Sample Input 2 | Sample Output 2 |
---|---|
1,-2,42,-5,3,2,-7 |
(1, -2, 42, -5, 3, 2, -7) |