Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What does None mean here?
#1
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
Reply
#2
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
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020