+ 1
try-except & Boolean
a = [4, 5, 6, 7] try: print(a[True]) except: print(a[0]) here is my question: [List a] has no elements associated with True. So, it won't trigger the condition of try. Only the condition of except will be triggered. All i know is [List a]'s first element is 4, so a[0] = 4 Why this code's output is 5 ?
3 Respostas