My loop at the bottom of my code doesn't seem to print song title if I type print SongList[i] it prints the memory address for the given object. I'm sure it's returning the Song List but the object attributes. Am I missing a method? Sorry if this has already been answered in the past I cannot find an example.
class Song:
def __init__(self, title, artist, duration = 0):
self.title = title
self.artist = artist
self.duration = duration
class Album:
def __init__(self, albumTitle, releaseYear, albumSize):
self.albumTitle = albumTitle
self.releaseYear = releaseYear
self.trackList = []
self.albumSize = albumSize
def addSong(self, albumSong, position):
self.trackList.append((position, albumSong))
class Artist:
def __init__(self, name, year):
self.name = name
self.year = year
self.members = []
def addMembers(self, bandMember):
self.members.append(bandMember)
class Person:
def __init__(self, name, age, gender):
self.name = name
self.age = age
self.gender = gender
BlinkAndSee = Album("Blink and See", 2018, 5)
Band = Artist("Dinkers", 2002)
AlexThomas = Person("Alex Thomas", 23, "Female")
SeanJohnson = Person("Sean Johnson", 25, "Male")
SineadMcAdams = Person("Sinead McAdams", 21, "Female")
Band.members.append(AlexThomas)
Band.members.append(SeanJohnson)
Band.members.append(SineadMcAdams)
Stoner = Song("Stoner", Band, 320)
Blink = Song("Blink and See", Band, 280)
See = Song("See", Band, 291)
DumbnessAndSand = Song("Dumbness and Sand", Band, 231)
OrangeYellow = Song("Orange Yellow", Band, 353)
BlinkAndSee.trackList.append(Stoner)
BlinkAndSee.trackList.append(BlinkAndSee)
BlinkAndSee.trackList.append(See)
BlinkAndSee.trackList.append(DumbnessAndSand)
BlinkAndSee.trackList.append(OrangeYellow)
SongList = BlinkAndSee.trackList
#Loop through the Song list from album tracklist
for i in range(SongList.__len__()):
print(SongList[i].title)