+ 1
Hi guys any can explain code why it not get increment i=i+1
What changes made in the code to get output [2,1,4,3] for the input [1,2,3,4] https://code.sololearn.com/c8lYcaBe4s9d/?ref=app
4 Respuestas
+ 8
https://code.sololearn.com/cAbTiXnYmoKV/?ref=app
+ 7
Just be careful when the length of list is odd
+ 2
I am not really sure about the practical purpose of a programm like this, but I did a try so that the user can give any order as target.
https://code.sololearn.com/cWAjurlohtWM/?ref=app
+ 2
Here an other try when matching pattern is always the same:
#output target -> [2,1,4,3]
a = [1, 2, 3, 4]
a[0],a[1],a[2],a[3] = a[1],a[0],a[3],a[2]
print(a)
[2, 1, 4, 3]