Hide

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 $l$ as a parameter.
In the tests, $l$ will be a list of length $0 \leq |l| \leq 1\, 000$. The elements of the list will be strings. You may assume all characters in the input are printable ASCII characters.

In the samples below, the first and only line of the input contains the elements of the list $l$ seperated by commas. The autograder will handle reading the input, splitting it on the commas and passing the resulting list as an argument to your function.

Output

The function should return one tuple $t$, the elments of list $l$ converted to integers.

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)

Please log in to submit a solution to this problem

Log in