DEV Community

Discussion on: Data Structures in Python: Dictionaries

Collapse
 
doshirae profile image
Doshirae

In that last exemple of code here :

if node_name in computer_list:
    print (computer_list.get(node_name))
else:
    print("Please use a designated computer for this program")

The get fonction has a second argument, that is a default if getting the first argument doesn't exist in the dict !

print (computer_list.get(node_name, "Please use a designated computer for this program"))
Collapse
 
georgeoffley profile image
George Offley

Good to know, I'm used to using the what I had.