if multiple exits, prefer while(1)loop

while 1 :
  if node is None: return None
  if node.key == k: return node.val
  node = node.next

The above exit condition is far more visible than in

while node is not None:
  if node.key == k: return node.val
  node = node.next
return None

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s