+ 2

had question in python quiz which came as a result of 5. Can someone explain the logic and why answer is 5.

https://code.sololearn.com/cOZZOOMo3GV2/?ref=app

15th Jun 2018, 7:39 AM
Chris Sheffield
Chris Sheffield - avatar
3 odpowiedzi
+ 4
ahhhh so since a has a [] it<gives value of 5 which is same as 1 meaning true?
15th Jun 2018, 8:01 AM
Chris Sheffield
Chris Sheffield - avatar
+ 4
On short, yes
15th Jun 2018, 8:29 AM
Alexandru Turculet
Alexandru Turculet - avatar
+ 3
The code gives an error, but from the looks of it, the reason could be the fact that comouters store the value true as 1 and the value false as 0 and printing will give the item at the index 1, which is 5.
15th Jun 2018, 7:58 AM
Alexandru Turculet
Alexandru Turculet - avatar