I need to loop through dictionary keys in the Enron dataset and check if string 'PRENTICE' is included in the keys and print the full key out.
I would approach it this way,
for string in enron_data.keys():
if "PRENTICE" in string:
value = string
print(value)
On Github I found however this solution, which of course also works:
values = [string for string in enron_data.keys() if "PRENTICE" in string]
What is the logic of this approach? Why is it in square brackets? When we write '[string' before the for loop, is this the same as in my case 'value = string' at the end?
Thank you very much for a clarification and apologies for a beginner questions.