+ 1
Why the output is 3?
list=[1,2,3,4,6] if len(list)%2!=0; print(list[max(list)%4]) else: print(list[min(list)]) the len is 4 indexes 4%2 =2 list max - 4%4 â>1 so why it is not 1 but 3 and what is min list -0?
3 Answers
+ 5
THEGreatGatsby , the length of the list is 5 (there are five elements in the list starting from index 0 to 4). So if conditional is true => 5%2! =0 and max element in the list is 6 => print (list [6%4]) => list[2] => 3. Hope now everything is clear đ±
+ 1
Just adding a note. Python is really strict when it comes to code indentation. As I see your code, all the lines are on the same indentation level, so I think this code is not running, at least until one fixed the indentation problem.
0
cool :)