I searched thoroughly but can't find anything relating to this exact specific. I have a list:
a = [two, three, one]
I want to move one
to the front, so it becomes:
a = [one, two, three]
The thing is, it could be ANY amount of numbers in the list. Assume there is no way of knowing whether there will be 50 items or 3.
Basically:
a.insert(0, a.pop())
Consider using collections.deque
if you're doing that often, though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With