Am new to python and am trying my hand on simulating how linked list works. I have the following code:
def mystery(x):
a , b = x , x.next.next
while b.next != None:
a.next.next = b.next
b.next = a.next
a.next = b
a = b
b = b.next.next
but when ever I give it the list 'x' which is x = ['1','2','3','4', '5'], I get the following error:
File "D:\workspace33\Quizes\src\tests.py", line 3, in mystery
a , b = x , x.next.next
AttributeError: 'list' object has no attribute 'next'
I was trying to simulate/visulaize the program on Online Python Tutor but I kept getting the same error. Can anyone let me know what am doing wrong or help me understand the process.
nextattribute? (they don't)x = ['1','2','3','4', '5'], are not linked lists.