+ 2

How can I check if a value is in a list is inside another list?

For example: [1, 2,3,4,[5,6]]

14th Mar 2019, 3:31 PM
Eliya Ben Baruch
Eliya Ben Baruch - avatar
2 Respuestas
+ 2
HonFu thanks and yes I meant the second option
14th Mar 2019, 6:10 PM
Eliya Ben Baruch
Eliya Ben Baruch - avatar
+ 1
I am not exactly sure if you mean that you want to know, if a list element *is* a list or if you want to know what's *in* the inner list. If you know where that inner list is exactly in a list called 'list_': print(5 in list_[4]) Otherwise you'd first have to find that list: for element in list_: if type(element) is list: print(5 in element)
14th Mar 2019, 4:13 PM
HonFu
HonFu - avatar