loading...

re: Data Structures in Python: Dictionaries VIEW POST

FULL DISCUSSION
 

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"))
 

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

Code of Conduct Report abuse