I'm executing the following snippet on python 2.7:
i=0
j=3
a=['A','B','B','A']
while(a[i]=="A" & i<j):
#do something
And I am getting this error.
TypeError: unsupported operand type(s) for &: 'str' and 'int'
Any help?
I'm executing the following snippet on python 2.7:
i=0
j=3
a=['A','B','B','A']
while(a[i]=="A" & i<j):
#do something
And I am getting this error.
TypeError: unsupported operand type(s) for &: 'str' and 'int'
Any help?
You need to put brackets around the two conditions like below.
i=0
j=3
a=['A','B','B','A']
while((a[i]=="A") & (i<j)):
#do something
refer below link for more detailed explanation Difference between 'and' (boolean) vs. '&' (bitwise) in python. Why difference in behavior with lists vs numpy arrays?