0

# Python list

lets say i have a list with coordinates: [(1,1), (2,2), (3,3)] and lets say that the first coordinates in the list (1,1), change to (5,5) for example, how would i change (2, 2) to (1,1) and (3,3) to (2,2) so basically each coordinates except the first one change to the place of where the coordinates in front of them used to be? so now the list would be [(5,5), (1,1), (2,2)]

7/28/2021 9:56:28 AM

Kirill Vidov

+6

a=[(1, 1), (2, 2), (3, 3) ] a.pop() a.insert(0,(5, 5))

+6

Oma Falk , list.push() is not yet implemented in python 🙂

+5

coords = [(5,5)]+coords[1:]

+4

Kirill Vidov , it was a joke from me addressed for Oma Falk, it does not need to be implemented, because list has: list.append(), list.extend() and list.insert().

+3

Oma Falk , maybe coords = [(5,5)]+coords[1:-1]

+2

Oma Falk what if we don't know how much coordinates are in the list?

+2

Lothar uuuuuups😉 Maybe queue has it.

+1

coords = [(0,0),(1,1),(2,2)] coords.push((5,5)) coords.pop(0)

+1

Abhay Oma Falk thank you

+1

Lothar do you know when will they implement it?

0

I think coords = [(5, 5)] + coords[:-1]