+ 2
How can I check if there is an element in a dictionary without using dicc.values?
for example: dicc={key:("mi", "car")} is ("mi", "car") in dicc??
13 odpowiedzi
+ 13
@Leshark it has! ~_~
+ 12
(@Alex check out other people posts too, they usually have "-3" votes, maybe someone created 3 fake accounts to troll……)
+ 1
The second one then
+ 1
Thank you
0
Obviously that was an example, i want to know how can I write that in python. I mean how can i check if a tuple is a value in a dictionary
0
Why the down-votes, if you want to check for tuples just do
>>> d = {(1, 2): ('A', 'B'), (3, 4): ('C', 'D')}
>>> (1, 2) in d
True
>>> d[(1, 2)]
('A', 'B')
>>> d[(1, 2)][0]
'A'
- 1
Alex, what are you doing? Stop spamming your not correct answers.
- 1
@ValentinHacker, seem's kinda pointless to do that in a Q&A section :/
@Leshark, it's not incorrect it's perfectly valid to check for tuples that way too, don't downvote someone becuase they offered a different way to do it.
- 2
@Alex, look at your answer and think a bit. You check is particular case, and my is not particular
@ValentinHacker, where? I can't find it in my ios app(
- 3
Yes it is in your dictionary, you created a tuple.
- 3
Iterate dictionary values and use type() fucntion
So:
type(dict[key]) == tuple
#True
P.S. JEES, ALEX STOP, IT IS INCORRECT!!!
- 3
This app need a report function:(
- 4
U have 2 different questions in main and example part. What to answer?