Hi guys any can explain code why it not get increment i=i+1 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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

15th May 2019, 1:10 PM
Raj J
Raj J - avatar
4 Answers
+ 8
https://code.sololearn.com/cAbTiXnYmoKV/?ref=app
15th May 2019, 2:05 PM
Rstar
Rstar - avatar
+ 7
Just be careful when the length of list is odd
15th May 2019, 2:06 PM
Rstar
Rstar - avatar
+ 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
15th May 2019, 2:44 PM
Lothar
Lothar - avatar
+ 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]
16th May 2019, 11:00 AM
Lothar
Lothar - avatar