this is probably a simpler question but I just don't seem to get how to do it. I have a list with strings, e.g.
my_list = ["a_foo", "b_foo"]
.
And I have a dictionary with keys as strings and my values are lists that contain strings, e.g.
my_dict = {"key_foo": ["a_bar"], "another_foo": ["c_bar", "False"]}
.
I tried to write a list comprehension that appends all key-value pairs to my existing list when the list does not contain "False". This is it
my_list.extend([[key, value] for (key, value) in my_dict.items() if 'False' not in value])
I get the output ["a_foo", "b_foo", ["key_foo", ["a_bar"]]]
. I absolutely understand why this is happening, however, I have not been able to find a way to make the output look like this instead: ["a_foo", "b_foo", "key_foo", ["a_bar"]]
. Could someone please explain how to do it? I would really appreciate it!