PY
py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
class Priority_Queue:
"""
This queue follows the same FIFO process except that higher priority
nodes will be dequeued before lower priority nodes. Nodes of the same
priority will follow the same FIFO process.
"""
# Text value and use number for priority.
class Node:
"""
Each node is the queue will have both a value and a priority.
"""
def __init__(self, value, priority):
"""
Initialize a new node
"""
self.value = value
self.priority = priority
def __str__(self):
"""
Display a single node
"""
# Error here
return "{0} (Pri:{1})".format(self.value, self.priority)
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run