Skip to content

Commit cc783a0

Browse files
committed
Don't use deprecated has_key() method
1 parent b6821e3 commit cc783a0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

‎graph_search.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def find_path(self, start, end, path=[]):
1717
self.path+= [self.start]
1818
ifself.start==self.end:
1919
returnself.path
20-
ifnotself.graph.has_key(self.start):
20+
ifnotself.startinself.graph:
2121
returnNone
2222
fornodeinself.graph[self.start]:
2323
ifnodenotinself.path:
@@ -33,7 +33,7 @@ def find_all_path(self, start, end, path=[]):
3333
self.path+= [self.start]
3434
ifself.start==self.end:
3535
return [self.path]
36-
ifnotself.graph.has_key(self.start):
36+
ifnotself.startinself.graph:
3737
return []
3838
paths= []
3939
fornodeinself.graph[self.start]:
@@ -51,7 +51,7 @@ def find_shortest_path(self, start, end, path=[]):
5151
self.path+= [self.start]
5252
ifself.start==self.end:
5353
returnself.path
54-
ifnotself.graph.has_key(self.start):
54+
ifnotself.startinself.graph:
5555
returnNone
5656
shortest=None
5757
fornodeinself.graph[self.start]:

0 commit comments

Comments
(0)