#S0013. 音乐播放列表
音乐播放列表
1. Description
Create a music playlist manager. Input operation commands to manage playlist. Initial list is empty. Supported operations:
add song_name duration(s) artist:Add song (duplicates by name not allowed)play [N]:Play Nth song (play first if no number, remove after playing)list:Show all songs (format: No.song_name(artist)-duration)remove artist:Remove all songs by artist Output "Operation failed" for invalid commands
2. Input & Output
Input:
- Multiple commands separated by semicolons
commands = input().split(';')
Output:
- Output results per command (
playoutputs "Now playing: song",listoutputs multiple lines)
Example
# Input:
add Nightwish 360 Floor;add Nemo 240 Floor;list
# 输出:
1.Nightwish(Floor)-360秒
2.Nemo(Floor)-240秒
# Input:
add Hello 300 Adele;play;play 2
# 输出:
Now playing: Hello
Operation failed