'Python - if statements and logical operators
I'm trying to do an if statements. This working fine :
with open(f, "r", encoding='mbcs') as csvfile:
reader = csv.reader(csvfile, delimiter='|')
for row in reader:
if 'codeclient' not in row[0]:
print ("Not found")
else:
print (row[0])
This one works too (see the difference)
with open(f, "r", encoding='mbcs') as csvfile:
reader = csv.reader(csvfile, delimiter='|')
for row in reader:
if 'ANONYM' not in row[3] :
print ("Not found")
else:
print (row[0])
But I'd like to check the content of two conditions like this,but it does not work
with open(f, "r", encoding='mbcs') as csvfile:
reader = csv.reader(csvfile, delimiter='|')
for row in reader:
if ('codeclient' not in row[0]) or ('ANONYM' not in row[3]) :
print ("Not found")
else:
print (row[0])
How could I check the 2 condition like this?
Many thanks
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
