Which method do you prefer when updating dict?

Asked 1 weeks ago, Updated 1 weeks ago, 1 views

When updating and adding elements of a dict object, I don't know how to do it neatly.

I understand that the following 2 methods are possible, which of the two do you prefer?

There may be factors that affect individual tastes, but I'm thinking about it because I feel that both are somewhat messy. ㅜ<

a = {original data}

# Method 1
b = {processed data}

# Method 2
a[processed data] = c
a[processed data] = d
a[processed data] = e

python dictionary

2022-09-20 11:35

1 Answers

I prefer the second one. I think it's more intuitive

2022-09-20 11:35

If you have any answers or tips

© 2022 pinfo. All rights reserved.