'How to write a changePriority function in priority queue with linked lists

I took this code from geeksForGeeks. Everything works fine. I am just trying to add changePriority Function which changes the priority of an item to a new priority.

I tried this. This is the link to full GeeksForGeeks code: https://www.geeksforgeeks.org/priority-queue-using-linked-list/

def changePriority(self, value, newPriority):
    while self.front:
        if self.front.data == value:
            self.front.priority = newPriority
        if self.front.priority >= self.front.next.priority:
            newNode = PriorityQueueNode(value,
                                        newPriority)
            newNode.next = self.front
            self.front = newNode

            return 1
        self.front = self.front.next


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source