Beginner Python. I have a list dictionary, for example:
d = {
1: ['foo', 'foo(1)', 'bar', 'bar(1)'],
2: ['foobaz', 'foobaz(1)', 'apple', 'apple(1)'],
3: ['oz', 'oz(1)', 'boo', 'boo(1)']
}
I am trying to figure out how to scroll through the dictionary keys and the corresponding list values and delete all the lines in each of the list with tail brackets. So far this is what I have:
for key in keys:
for word in d[key]...:
regex = re.compile('\w+\([0-9]\)')
re.sub(regex, '', word)
I would like to do this with a list, but, as I said, I cannot find much information about the loop with the dict keys and the corresponding bits value in the list. What is the most efficient way to customize?
source
share