I have this code :
selected_listbox_select_criteria_column = [('0', 'firstName'),('1', 'lastName'),('2', 'phone')]
column_to_check_for_criteria = []
column_to_check_for_criteria(', '.join(elems[0] for elems in selected_listbox_select_criteria_column))
It gives me this result :
['0,1,2']
How can I have a strict list of integer like this :
[0,1,2]
without the quotes to finally get equivalent of : column_to_check_for_criteria = [0,1,2]
Thanks
The issue you are facing is the additional work you don't need to be doing with your
', '.join(...)call. It seems what you are trying to do is to simply extract in to a list the integer values as integer type from your list of tuples. To do this, based on the code you are writing, you don't need to use thatjoin. You can simply use a list comprehension and cast eachelems[0]toint. This should give you the expected output:Running that will now give you
As added information, you would typically use a
joinwhen you want to turn a list in to a string. An extra little note about usingjoinis that expects an iterable of typestringand notint. You can't actually use it on a list of integers. Observe the following two examples:This will fail
This will not