Question: Python 3 How do i fix TypeError: __init__() missing 1 required positionalargument: 'next' on head1=tall=Node(i). class Node(object): item = -1 next = None def __init__(self,item,next):

Python 3

How do i fix TypeError: __init__() missing 1 required positionalargument: 'next' on head1=tall=Node(i).

class Node(object):

item = -1

next = None

def __init__(self,item,next):

self.item = item

self.next = next

def merge_lists(vivendi, activision):

head = tail = Node(0)

while vivendi and activision:

if vivendi.item

tail.next = vivendi

vivendi = vivendi.next

else:

tail.next = activision

activision = activision.next

tail =tail.next

tail.next = vivendi or activision

return head.next

def printRepeating(mergeLists,size):

print("Repeating ID's are ", end = '')

for i in range(0, size):

for j in range(i+1,size):

if mergeLists[i]==mergeLists[j]:

print(mergeLists[i],"", end = '')

if __name__ =='__main__':

vivendi = []

with open('vivendi.txt', 'r') as myfile:

for line inmyfile:

vivendi.append(int(line.strip()))

#print(vivendi)

head1=tall=None;

for i in vivendi:

if(head1==None):

head1=tall=Node(i)

else:

tall.next=Node(i)

tall=tall.next

activision = []

with open('activision.txt', 'r') asmyfile:

for line inmyfile:

activision.append(int(line.strip()))

#print(activision)

head2=tall2=None;

for i in activision:

if(head2==None):

head2=tall2=Node(i)

else:

tall2.next=Node(i)

tall2=tall2.next

new_head=merge_lists(head1,head2)

mergeLists = []

count = 0

while new_head:

mergeLists.append(new_head.val)

new_head=new_head.next

count=count+1

printRepeating(mergeLists,count)

Step by Step Solution

3.40 Rating (156 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Python version 36 Python program to update the given program to remove syntax errors class Nodeobjec... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Electrical Engineering Questions!