s.insert(0, x)
It's usually written like this.
I don't know what code you're using, but if you're putting an element at the forefront of the list when the speed of performance is important, I recommend you use this
As you can see from the document, the insert (0, x) in the list is O(n) class collections.deque([iterable[, maxlen])'s queue() is O(1) so if speed is important, use this one
© 2024 OneMinuteCode. All rights reserved.