So I have something like:
d = {'d':[' Cool Guy', ' Cool Gal']}
How do I remove the space inside the key-value so my output would be
d = {'d':['Cool Guy', 'Cool Gal']}
I appreciate the help, thank you.
So I have something like:
d = {'d':[' Cool Guy', ' Cool Gal']}
How do I remove the space inside the key-value so my output would be
d = {'d':['Cool Guy', 'Cool Gal']}
I appreciate the help, thank you.
d = {'d':[' Cool Guy', ' Cool Gal']}
for key in d:
d[key] = [ls.strip() for ls in d[key]]
d = {'d':[' Cool Guy', ' Cool Gal']}
for k, v in d.items():
new_d = {k:[elem[1:] for elem in v]}
print(new_d)
Output:
{'d': ['Cool Guy', 'Cool Gal']}
Logic:
k
) and corresponding value list (v
).