user13284053
user13284053

Reputation:

Can Bool value be multiple with tuple

Whats the concept, why 7 is printed and 5 isn't? What operations are these?

x,y=5,0
test=x**y>0
ans=(5,7)[test]
print(ans)

Upvotes: 3

Views: 34

Answers (1)

Sami Fakhfakh
Sami Fakhfakh

Reputation: 125

because test will be true so ( 1 )

and your tuple have two values : 0 -> 5 , 1 -> 7 ,

it's logic that ans will containt (5,7)[1] = 7

Upvotes: 2

Related Questions