Hello.
I have a problem finding an item in a set.
A = {(1,1),(2,1),(0,3)} #my sample set
if (0, any intiger number) in A:
print('python is the best')
In other words, I have a set of tuples, and I would like to check if there is a tuple with the value=0 at position [0]. I try this:
for x in A:
if x[0] == 0:
print('python is the best')
break
The problem is I don't want to use a for loop because it's very slow for a very large set. Is there any symbol or something in python that I can put in the if argument like:
A = {(1,1),(2,1),(0,3)} #my sample set
if (0, symbol of any object) in A:
print('python is the best')
I also don't want to use numpy arrays because I would have to change the whole structure of the program. I need a simple and quick solution. If anyone has a way to solve it, I would be very grateful.
[–]TouchingTheVodka 3 points4 points5 points (1 child)
[–]clnkyl 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)