Skip to content

Commit 37328cc

Browse files
author
Bakhtiyor Ruziev
committed
Add check for a queue emptiness
1 parent 5a99356 commit 37328cc

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

data_structures/queue/queue.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ def put(self, item):
1717
self.length += 1
1818

1919
def get(self):
20+
if self.length <= 0:
21+
return
2022
self.length -= 1
2123
de_queued = self.entries[self.front]
2224
self.entries = self.entries[1:]

0 commit comments

Comments
 (0)