i want to replace the unit digits of first number and last number, second number and second last number and so on. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

i want to replace the unit digits of first number and last number, second number and second last number and so on.

Python list assignment n=int(input()) p=n a=[i for i in input().split()] for i in range(n//2): f=list(str(a[i])) g=list(str(a[p-1])) f[-1],g[-1]=g[-1],f[-1] p-=1 print(a) Why replace is not happening? https://code.sololearn.com/cxXBidyV44cK/?ref=app

22nd Dec 2018, 2:12 PM
Mallika Das
Mallika Das - avatar
1 Answer
+ 1
If you print f and g at the end of the loop, you will see, that it works. However you still need to change a then :)
22nd Dec 2018, 3:13 PM
Matthias
Matthias - avatar