Explanation:
๐น Step 1: Create List
x = ["A","B"]
A list is created:
Index 0 → "A"
Index 1 → "B"
Visual:
["A", "B"]
๐น Step 2: Understand Boolean Values
In Python:
True = 1
False = 0
⚠️ Important:
Booleans behave like integers ๐
๐น Step 3: Evaluate x[True]
x[True]
Since:
True = 1
Python actually does:
x[1]
At index 1:
"B"
So:
x[True] → "B"
๐น Step 4: Evaluate x[False]
x[False]
Since:
False = 0
Python actually does:
x[0]
At index 0:
"A"
So:
x[False] → "A"
๐น Step 5: Print Result
print("B", "A")
๐ Final Output:
B A
๐ฅ Final Output
B A

0 Comments:
Post a Comment