Back
I need an explanation of why the output is A for the following code is.
a = Trueprint (('A','B')[a == False])
a = True
print (('A','B')[a == False])
Assuming the first line is a = True, a == False evaluates to false, therefore the boolean value of 0. Therefore your expression is same as the print(('A', 'B')[0]) which prints 'A'
Do check out Python Data Science Course which helps you understand from scratch
31k questions
32.8k answers
501 comments
693 users