0
Moving elements in a list
I need to move the last three elements from the end of a list to the start in the same order. Is this code correct? y = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] y[:0] = y[-3:] del y[-3:] Can I do it with a single line of code? Sorry for my bad english...
4 Respuestas
+ 3
print(y[-3:]+y[:-3])
+ 5
y = y[-3:] + y[0:-3]
https://code.sololearn.com/c2fSY40O53Df/?ref=app
+ 1
Thank you
+ 1
You're welcome.