I'm relatively new to python and want to do something like:
if value x == any value in list y:
write x
this would operate wihtin a function, so only solutions which match a certain criteria would write to csv as they are generated
>>> x = 8
>>> if x in (1, 2, 3, 5, 8, 13, 21, 34, 55):
print('x is an early Fibonacci number')
x is an early Fibonacci number
You may use the in syntax:
if x in ["a", "b", "c"]
... do stuff
And also if you care about the number of occurances of x you may use count:
if y.count(x) == 1
... do stuff
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With