What happens if get_value() is called on get_link_node() and that value is None?


#1

Question

In this exercise, the data is obtained using calls of the format get_link_node().get_value(). What will happen if get_link_node() returns a None in this case?

Answer

In the event that get_link_node() returns None and there is no check before get_value() is called, then the following error will be returned by Python during runtime. As a general rule, it is best to check that a valid link is returned before attempting to access the data.

AttributeError: 'NoneType' object has no attribute 'get_value'