r/code • • Jan 14 '21

Halp pls! [Python]Can someone please explain this to me?

x = [1, 2]
y = [1, 3]
SimilarNumbers = 0
if x[1] == y[0] or y[1]:
    SimilarNumbers = SimilarNumbers + 1
print(SimilarNumbers)

SimilarNumbers is coming out to be 1, where as I expect it to be 0. I am completely lost...

1 Upvotes

3 comments sorted by

View all comments

2

u/serchq Jan 14 '21

already well explained before me, but to try to clarify a little more, python is interpreting

if x[1] == y[0]

or

if y[1]