PYTHON 22
4/22/2025 Song class in python Guest on 23rd April 2025 12:45:43 AM
  1. # A Song class to contain a song title and it's artist
  2. class Song:
  3.         def __init__(self, title, artist):
  4.                 self.title = title
  5.                 self.artist = artist
  6.  
  7.  
  8.         # Print the values of the song as the object representation
  9.         def __str__(self):
  10.                 full_song_representation = self.title + " by " + self.artist
  11.                 return full_song_representation

Paste is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.