Python Forum

Full Version: What does None mean here?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
What does None mean here?
Does it mean that it should be initialized as empty, but if there is input it can be overridden?
class ListNode:
    
    def __init__(self, data=None, next=None):
        self.data = data
        self.next = next
None is default value of data and next. If you don't pass any of these during instantiation of the class object it will use the default values.

as a side note next is built-in function, better don't use it as param name