Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

Python version 36 Python program to update the given program to remove syntax errors class Nodeobjec... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Electrical Engineering questions