0

list = [1, 2, 3, 4, 6]

list = [1, 2, 3, 4, 6] if len(list)%2 !=0: print(list[max(list)%4]) else: print(list[min(list)]) OUTPUT: 3 # If the length of the list, when divided by two, has remainders that do not equal zero we go to else ( 1 and 3 when divided by two do not have 0 remainders, so we go to else). #print(list[min(list)])? Two, four and six are the minimum numbers when divided by 2 with a remainder zero? Is that what's going on? Any help appreciated.

12th Apr 2019, 10:16 PM
tristach605
tristach605 - avatar
1 Resposta
+ 2
I don't see where's the point of confusion here. Let's break it down. if len(list) %2! =0 here, len(list) = 5 and 5%2 is not equal to 0, hence the condition is true. Now list[max(list)%4] here, max(list) =6, and 6%4= 2 and list[2] is 3. Hence the output 3.
13th Apr 2019, 12:45 AM
Шащи Ранжан
Шащи Ранжан - avatar