0

I'm unable to get the unique items in my dictionary please anyone help it......

test_list={ 'Rahul': {'Permanent Roomates': 2, 'Inside Edge': 3, 'Four More Shots Please': 3, 'Sacred Games': 3, 'Apharan': 2, 'Mirzapur': 3}, 'Rishabh': {'Permanent Roomates': 3, 'Inside Edge': 3, 'Sacred Games': 5, 'Mirzapur': 3, 'Apharan': 3}, 'Sonali': {'Permanent Roomates': 2, 'Inside Edge': 3, 'Sacred Games': 3, 'Mirzapur': 4}, 'Ritvik': {'Inside Edge': 4, 'Apharan': 2, 'Sacred Games':4 }, 'Harshita': {'Permanent Roomates': 4, 'Inside Edge': 4, 'Four More Shots Please': 2, 'Sacred Games': 3, 'Mirzapur': 3, 'Apharan': 2}, 'Shubhi': {'Permanent Roomates': 3, 'Inside Edge': 4, 'Mirzapur': 3, 'Sacred Games': 5, 'Apharan': 3}, 'Shaurya': {'Inside Edge':4, 'Apharan':1, 'Sacred Games':4}} res = list(set(val for dic in test_list for val in dic.value())) print("the unique value in list: " + str(res)) # Q - Extract

23rd Jun 2021, 5:23 PM
Akash Gupta
Akash Gupta - avatar
7 ответов
+ 2
Akash Gupta What about this? setkey = set() for id, info in test_list.items(): for key in info: setkey.add(key) print (setkey)
23rd Jun 2021, 5:40 PM
A͢J
A͢J - avatar
+ 1
Which one is unique according to you?
23rd Jun 2021, 5:37 PM
Ipang
+ 1
Ipang as you seen in my dictionary there is 4 or 5 keys and those keys have some value which will same in different key so i want to print that value in my output. Sorry for bad English
23rd Jun 2021, 5:56 PM
Akash Gupta
Akash Gupta - avatar
+ 1
""" Akash Gupta as that's only the first part of your assignement, and the second part is to find comon series between two customers, I will rather build a new dict structure with series as keys, and storing list of customers as values: """ series = {} for c, d in dataset.items(): for t in d: if t in series: series[t].append(c) else: series[t] = [c] print("uniques series:") print(*series.keys(), sep="\n") # the 'series' dict will now help you to solve the second question ^^
23rd Jun 2021, 6:10 PM
visph
visph - avatar
+ 1
Akash Gupta Kaun sa value print karna hai? Is it like this? https://code.sololearn.com/cde6eYO63CIx/?ref=app
23rd Jun 2021, 6:45 PM
A͢J
A͢J - avatar
+ 1
🅰🅹 🅐🅝🅐🅝🅣 ,visph thank you so much for giving your time.
24th Jun 2021, 8:47 AM
Akash Gupta
Akash Gupta - avatar
23rd Jun 2021, 5:59 PM
Akash Gupta
Akash Gupta - avatar