Assuming 'm' is a series with index as 1,2,....12 and values as jan, feb,....dec,
var = 1
if var in m:
print(var*20)
In above, the condition checks if 'var' is present in the index of m (1,2.....12) and prints 20
But, when 'in' is used in a for statement, it iterates through the series' values instead of series' index
for var in m:
print(var)
Above, prints all the month names (jan, feb..... dec)
Why is that the 'in' of the first piece of code (if block) searches in series index and the 'in' of the for statement iterates through the values of the series. Why is the behavior inconsistent ? Is there an explanation/logic behind this ?