배열/딕셔너리 선언 및 호출
1-1. 배열/딕셔너리별 선언형태
-
배열
▶array=[]
-
딕셔너리
▶dictionary = {}
-
배열내 딕셔너리 :
▶dictionary_in_array = [{key:value},{'key':value}]
▶key 값은 정수 혹은 '문자열' 형태 모두 가능!
1-2. 배열/딕셔너리별 호출형태
-
배열 :
▶array[index]
-
딕셔너리 :
▶dictionary[key]
-
배열내 딕셔너리 :
▶dictionary_in_array[0]
dictionary_in_array[0][key]
▶value/key 값 모두(인덱스접근) or value 값(인덱스-key접근)
2. 코드
dictionary = {
'pencil' : 3500,
'pen' : 2500,
'notebook' : 3000,
5000 : 1500
}
#print(dictionary[0]) #출력불가
#pint(dictionary{'pencil'}] #출력불가
print(dictionary['pencil']) #정상출력
print(dictionary[5000]) #정상출력
array = [1, 2, 3]
print(array[0]) #정상출력
dictionary_in_array = [{'pencil': 3500}, {'pen' : 2500}]
print(dictionary_in_array[0]) #정상출력
print(dictionary_in_array[0]['pencil']) #정상출력
3-1. 참조링크
https://blockdmask.tistory.com/429
https://araikuma.tistory.com/357
4. remind
코드에 대한 이해가 우선이다. Not sugar syntax But sugar logic!
Author And Source
이 문제에 관하여(배열/딕셔너리 선언 및 호출), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://velog.io/@gyrbs22/배열딕셔너리-선언-및-호출저자 귀속: 원작자 정보가 원작자 URL에 포함되어 있으며 저작권은 원작자 소유입니다.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)