how to print lists inside tuple in python [closed]
i got lists inside a tuple. At least i think thats what i have (i did not code it):
nvts = {"high": [], "medium": [], "low": [], "log": []}
I want to print the values inside "high", "medium" etc.
i tried a for-loop:
for a, *b in nvts:
print(a, ' '.join(map(str, b)))
but it gives me as an output:
h i g h
m e di u m ...
Can someone help me with the correct print?
best regards
Solution 1:
I didn't quite understand whether you want the values for each key, if so something like:
nvts = {"high": [],
"medium": ["value1"],
"low": ["value 2","value 3"],
"log": ["more value", "even more value"]}
print("\n".join([item for sublist in nvts.values() for item in sublist]))
outputs:
value1
value 2
value 3
more value
even more value
if you just want to print the keys:
print("\n".join(nvts.keys()))
outputs
high
medium
low
log