Skip to content

Instantly share code, notes, and snippets.

@oiojin831
Last active July 19, 2021 04:00
Show Gist options
  • Save oiojin831/7849368f8ffb89b9de638ab9957d19c1 to your computer and use it in GitHub Desktop.
Save oiojin831/7849368f8ffb89b9de638ab9957d19c1 to your computer and use it in GitHub Desktop.
import random
movies = []
while True:
print("*" * 30)
print("1. 영화 추가")
print("2. 영화 보기")
print("3. 랜덤 영화 고르기")
print("4. 감독 추가하기")
print("5. 새로운 속성 추가하기")
print("6. 종료")
num = int(input("번호를 적어주세요"))
if num == 1:
title=input("영화의 이름을 적어주세요")
year=input("개봉 연도를 적어주세요")
movie={"title": title, "year": year}
movies.append(movie)
elif num == 2:
idx = 0
for movie in movies:
print(idx, movie)
idx = idx + 1
elif num == 3:
print(random.choice(movies))
elif num == 4:
movie_index = int(input("감독을 추가하고 싶은 번호"))
movies[movie_index]["감독"] = input("감독이름을 적어주세요")
elif num == 5:
movie_index = int(input("새로운 속성을 추가하고 싶은 번호"))
new_key = input("새로운 속성의 이름을 입력해 주세요")
new_value = input("새로운 속성의 내용을 입력해 주세요")
movies[movie_index][new_key] = new_value
elif num == 6:
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment