I'm trying to write a class to randomly pick a number of songs from a dictionary. The whole point of it is to be able to simply type DJ.chooseListing()
for example to execute the random selection. Alas it gives me an error I can't really find anywhere else on the web, and I feel the answer is very simple.
class DJ:
# put song variables here in this format: trackName = Track("string of song to be displayed", 'music/filename.ogg')
trackRickAstleyNever = Track("Never gonna give you up", 'music/rick.ogg')
trackShootingStars = Track("Shooting Stars", 'music/shoot.ogg')
dictSongs = {
# put songs here like this: 'name': varName,
'nevergonnagiveyouup': trackRickAstleyNever,
'shootingstars': trackShootingStars,
}
"""
arrayRandomized = [
# Put future songs here in this format: songs['name'],
]
"""
arrayChosen = []
trackChosen = ""
def chooseListing(self):
for i in xrange(4):
self.arrayChosen.append(random.choice(self.dictSongs))
def chooseTrack(self):
self.trackChosen = random.choice(self.arrayChosen)
DJ.chooseListing()
IndentationError
. Unless that's the problem you're asking about, you need to fix it. – Aloysiaclass XX:
line. Please make sure that if you're pasting Python code you reproduce your indentation accurately, otherwise you are introducing new errors into the code you are asking people to read. – Aloysia