728x90
반응형
playlist = {}
def add_song(song):
if song not in playlist:
playlist[song] = True
print(f"{song} 음악 추가!")
else:
print(f"{song} 음악이 이미 았습니다!")
def remove_song(song):
if song in playlist:
del playlist[song]
print(f"{song} 음악삭제")
else:
print(f"{song} 음악이 없습니다!")
# 예제 사용법
add_song("음악 1")
add_song("음악 2")
add_song("음악 3")
print(playlist)
add_song("음악 2")
remove_song("음악 2")
print(playlist)
728x90
반응형
'프로그램' 카테고리의 다른 글
[파이썬] 문제 : 사용자 정보 파일로 관리 (0) | 2023.04.29 |
---|---|
[C언어] 4진수 변환 (0) | 2023.04.29 |
[C언어] 2개의 실수 입력 받아서 두 실수 사이의 정수 합 표시 (0) | 2023.04.28 |
[파이썬] 문제 : 회원가입 (0) | 2023.04.28 |
[C언어] 입력 받은 정수 라인만큼 삼각형 모양 정수 리스트 하기 (0) | 2023.04.28 |
댓글