DEV Community

Discussion on: Data Structures in Python: Dictionaries

doshirae profile image

In that last exemple of code here :

if node_name in computer_list:
    print (computer_list.get(node_name))
    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"))
georgeoffley profile image
George Offley Author

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