Feb-04-2020, 10:20 AM
This is homework and no effort shown....
However, for learning purposes I provide alternative which should be shorter and without using 'temp':
However, for learning purposes I provide alternative which should be shorter and without using 'temp':
>>> recs = {1: ['Susan Smith', '[email protected]'], 2: ['Cole Brown', '[email protected]'], 3: ['Sue John', '[email protected]']} >>> for key in recs: ... recs[key] = [item.replace('.com', '.org') for item in recs[k]] ... >>> recs {1: ['Susan Smith', '[email protected]'], 2: ['Cole Brown', '[email protected]'], 3: ['Sue John', '[email protected]']}If values are consistent and their structure doesn't change then no need to iterate over all items and rebuild the whole list, only change second value (changing .org back to .com):
>>> for key in recs: ... recs[key][1] = recs[key][1].replace('.org', '.com') ... >>> recs {1: ['Susan Smith', '[email protected]'], 2: ['Cole Brown', '[email protected]'], 3: ['Sue John', '[email protected]']}
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.