Apr-24-2020, 04:53 AM
Hi,
I'm trying to get a better understanding for "and" in a loop. For the script below, I'm trying to get index 1, but it returns index 1 and 2.
if I change it like this, and expected no returns (cause none item in b has "bc" and "cd" at the same time), it actually gives me index 1 and 2 again.
I'm trying to get a better understanding for "and" in a loop. For the script below, I'm trying to get index 1, but it returns index 1 and 2.
b = ["abc", "bcd","cde"] for i in range(len(b)): if "b" and "d" in b[i]: print (i)
if I change it like this, and expected no returns (cause none item in b has "bc" and "cd" at the same time), it actually gives me index 1 and 2 again.
b = ["abc", "bcd","cde"] for i in range(len(b)): if "bc" and "cd" in b[i]: print (i)Can someone help? Thanks!