Created
July 12, 2021 05:30
-
-
Save oiojin831/df1e3278abe01738feddefc1f80eb242 to your computer and use it in GitHub Desktop.
day2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
# list 복습하기 | |
movies = ["어벤져스", "헐크", "블랙 위도우"] | |
# 0번 부터 시작 | |
# 1번째에 있는 요소 접근하기 | |
print(movies[1]) | |
# 2번째에 있는 요소 변경하기 | |
movies[2] = "아이언맨" | |
print(movies) | |
print(movies[2]) | |
# 리스트에 요소 추가하기 | |
movies.append("토르") | |
print(movies) | |
# for loop 사용하기 | |
for x in range(10): | |
print(x, random.choice(movies)) | |
for movie in movies: | |
print("내가 좋아하는 영화는", movie) | |
# dictionary | |
movie_detail_data = [ | |
{"title": "어벤져스", "year": 2012}, | |
{"title": "헐크", "year": 2008}, | |
{"title": "아이언맨", "year": 2010} | |
] | |
print(movie_detail_data[1]) | |
print(movie_detail_data[1]["title"]) | |
new_movie = {} | |
new_movie["title"] = "superman" | |
new_movie["year"] = 1990 | |
movie_detail_data.append(new_movie) | |
print(movie_detail_data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment