0

Someone can explain me this code? 'Class Player'

class Track: def __init__(self, title, next): self.title = title self.next = next class Player: def __init__(self): self.head = None def add(self, title): if not self.head: self.head = Track(title, None) return curr = self.head while curr.next: curr = curr.next curr.next = Track(title, None)

23rd Aug 2022, 7:24 PM
Josué Varela
Josué Varela - avatar
2 Answers
+ 2
Oh... technically it is a single linked list. If the playlist is not empty, you must find the tail to add a title. There are lessons for it in SL.
24th Aug 2022, 5:19 AM
Oma Falk
Oma Falk - avatar
+ 1
It looks like a music player. The first class makes two functions for title and next. The player class looks like its made to add new songs but it hard to tell without additional context.
23rd Aug 2022, 7:52 PM
Shakwon Dyas
Shakwon Dyas - avatar