Skip to content

Initialize class instance in a loop over a list

I have a class where I assign a rating to each instance. I would like to be able to loop over a list of ratings, and create an instance for each rating, so if I have a list of ratings and team names, something like this: The above is not defining an instance of Team like I want it to.

Defining two objects at once using list comprehension

I have a list of dicationaries list_dic each containing the keys id;name. From those keys I’d like create two lists. I would like to use a list comprehension for this task, e.g. The issue here is I’m looping twice which is probably not a smart thing to do. Is there a way to use a list comprehensio…

Renaming mp3 files with random ending in filename

I have a folder with files named like this “artist – track XX XXX.mp3” what I’am trying to do is have the files renamed to just “artist – track.mp3” the last part of the file will always begin one of these: [1B, 2B, 3B, 4B, 5B, 6B, 7B, 8B, 9B, 10B, 11B, 12B, 1A, 2A, 3…