Home>
ids= {'user1': [213, 213, 213, 15, 213],
'user2': [54, 54, 119, 119, 119],
'user3': [213, 98, 98, 35]}
for i in ids.values():
i1= set(i)
print(i1)
I sorted the lists by turning them into sets, so that there would be no repetitions in the lists. Now I need to put all these sets in one list, I could do it through '|' , but all these sets are already in one variable. Tell me how to do it? Maybe you need to do it differently?
List of numbers, now sets
Диана Тихонова2022-02-13 13:02:17-
Answer # 1
You can do this:
ids= { 'user1': [213, 213, 213, 15, 213], 'user2': [54, 54, 119, 119, 119], 'user3': [213, 98, 98, 35], } result= set() for i in ids.values(): result |= set(i) print(result)
-
Answer # 2
You can do this:
ids= { 'user1': [213, 213, 213, 15, 213], 'user2': [54, 54, 119, 119, 119], 'user3': [213, 98, 98, 35], } result= set() for i in ids.values(): result |= set(i) print(result)
Trends
- python - you may need to restart the kernel to use updated packages error
- dart - flutter: the instance member'stars' can't be accessed in an initializer error
- php - coincheck api authentication doesn't work
- php - i would like to introduce the coincheck api so that i can make payments with bitcoin on my ec site
- [php] i want to get account information using coincheck api
- the emulator process for avd pixel_2_api_29 was killed occurred when the android studio emulator was started, so i would like to
- javascript - how to check if an element exists in puppeteer
- sh - 'apt-get' is not recognized as an internal or external command, operable program or batch file
- i want to check the type of a shell script variable
- i want to call a child component method from a parent in vuejs
It is not clear what specific result you want to get in the end? List of numbers? Lots of numbers? List of sets of numbers?
andreymal2022-02-13 12:57:36