Q. Write a program that checks if two same values in a dictionary have different keys.
You can understand by Watching video :-
Answer :-
dic = eval(input("Enter a dictionary = ")) count = 0 lst = list (dic.values()) for i in lst : a = lst.count(i) if a > 1 : count += a for j in lst : if i == j : lst.remove( j ) if count == 0 : print( "no values are same " ) else : print( count,"values are same ")
Output :-
Enter a dictionary = {"Path":1,"Walla":9,"Portal":1,"Express":2}
2 values are same
>>>
Enter a dictionary = {"Path":1,"Walla":9,"Portal":5,"Express":2}
no values are same
>>>
Enter a dictionar = {"Python":2, "C++":3,"Java":2,"CSS":2}
3 values are same
>>>
What is the purpose of j loop?
ReplyDeletePlease Watch video. I have explained it properly.
Deleteif i and j were same than the 'j' will be removed because of duplicate values
Deletethank for helping
ReplyDeleteWelcome : )
Deleteplease give us mind map for jee 2026
ReplyDeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )