about python list derivation, if else always doesn"t understand. Ask God to know
, as shown in the following code
list_range=[1,2,3,4,5]
cnum=5
list_range[(cnum-3) if (cnum-3)>0 else 0:cnum-1]
the final output result is [3br 4]
according to my understanding, if cnum=5, satisfies the if condition, then it should be list_range [2], that is, the output value should be 3, and now the output is [3Power4]
puzzling ah, is it possible that after meeting the conditions, the value of cnum-3 will replace the 0 in front of 0:cnum-1?