Gingerbread Gingerbread - 1 month ago 10
Python Question

Python-list expression output

a=["four", "score", "and", "seven", "years"][[0,2,3][1]]


print(a)

output is :
and


What is the main logic of this expression ?

Answer

[0,2,3][1] gives 2 which goes into ["four", "score", "and", "seven", "years"][2] which in turn returns and.

Comments