Notice
Recent Posts
Recent Comments
Link
์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
Tags
- execCommand
- async
- database
- ๋น๋๊ธฐ
- eport
- Porject
- await
- object
- sql
- js
- ๋๊ธฐ
- https://youtube.com/playlist?list=PLuHgQVnccGMA5836CvWfieEQy0T0ov6Jh&si=FTaYv8m21EhO-A2K
- callback
- setTimeout()
- https://m.blog.naver.com/tt2t2am1118/221010125300
- ์ฐธ๊ณ ๋ธ๋ก๊ทธ
- addEventListener
- webpack
- Project
- slow and steady
- ajax
- JS #ํ๋ก์ ํธ
- mysql
- ๊ฒ์
- promise
- ํผํ
- db
- prj
- Import
- json
Archives
- Today
- Total
C-log
๐กโจ์ค๊ฐ์ ๊ฒ : map๊ณผ list ๋ณธ๋ฌธ
728x90
*map์ ์ด์ฉํ input ๋ฐ๊ธฐ
์ด์ ๊น์ง map์ ์ด์ฉํด์ ์ฌ๋ฌ๊ฐ์ง ๊ฐ์ ์ ๋ ฅ๋ฐ์๋ค. ๊ธฐ๋ณธ์ ์ผ๋ก ์๋์ ๊ฐ์ด ์ฌ์ฉํ๋ค. ๊ฐ๊ธฐ int๋ก ๊ฐ ๋ณ์์ ์ ๋ ฅ์ ๋ฐ๋๋ค.
A, B = map(int, input().split())
print(f"{A} and {B} type : {type(A)}")
123 123
123 and 123 type : <class 'int'>
123 and 123 type : <class 'int'>
2๊ฐ์ง์ ๋ณ์์ 2๊ฐ์ง ๊ฐ์ ์ ๋ ฅ๋ฐ์ ๋ ๋ณดํต ์ด๋ ๊ฒ ์ ์๋ค. ํ์ง๋ง ํ๋์ ๋ณ์์ ์์ ๊ฐ์ ๋ฐฉ์์ผ๋ก ๊ฐ์ ๋ฃ์ผ๋ฉด ์๋์ ๊ฐ์ ๊ฒฐ๊ณผ๋ฅผ ์ป๋๋ค.
N = map(int, input().split())
print(f"{N} type : {type(N)}")
123
<map object at 0x000001FB10A1A530> type : <class 'map'>
<map object at 0x000001FB10A1A530> type : <class 'map'>
๋ฐ๋ก ํด๋น ๋ณ์์ ํ์ ์ด map์ผ๋ก ๋์ค๊ธฐ ๋๋ฌธ์ด๋ค. ์ด๋ฅผ ํ๋์ ๋ณ์๋ก ๋ด์์ ์ฌ๋ฌ ์ ๋ ฅ๋ฐ์ ๊ฐ์ list๋ก ๋ด์๋ด์ผ ์ฐ๋ฆฌ๊ฐ ์ฌ์ฉํ๊ธฐ ์ฌ์ด ํํ๋ฅผ ๋ง๋ค ์ ์๋ค. ์๋ ์ฝ๋๋ list๋ก ๋ด์๋ธ ๋ชจ์ต์ด๋ค.
*mapํจ์๋ฅผ ์ด์ฉํ list
N = list(map(int, input().split()))
print(f"{N} type : {type(N)} type : {type(N[0])}")
123 123
[123, 123] type : <class 'list'> type : <class 'int'>
[123, 123] type : <class 'list'> type : <class 'int'>
*list.py ํ์ธํ๊ธฐ
# for๋ฌธ์ ์ฌ์ฉํด์ ์
๋ ฅ๊ฐ ๋ฐ๊ธฐ
# N = list(map(int, input().split())) # int list ์์ฑ
# print(N)
# N = list(input().split()) # str list ์์ฑ
# print(N)
# ์๋ชป๋ ๋์
๋ฐฉ๋ฒ
# for _ in range(2):
# # N = [map(str, input().split())] # ์ ์ฌ๊ธฐ์ ์ถ๊ฐ๋์ง ์๋ ๊ฑฐ ์ฒ๋ผ ๋ณด์ด๋๊ฐ.
# # for๋ฌธ์ ๋๋ ค๊ฐ๋ฉฐ ๊ฐ์ ์๋ก ์์ฑํ๋ค. ์ฆ, N์ ์๋ก์ด list๋ฅผ ๊ณ์ํด์ ํ ๋นํ๋ ๊ฒ์ด๋ค. ๊ทธ๋์ ๋ง์ง๋ง์ ์
๋ ฅํ list๋ง ์๋ for๋ฌธ์์ ํ์ธ์ด ๋๋ ๊ฒ์ด๋ค. ๋ฐ๋ผ์ N์ list์ฒ๋ผ ๊ณ์ ํด์ ๊ฐ์ ๋ฃ๊ธฐ ์ํด์ append๋ฅผ ์ฌ์ฉํด์ผํ๋ค.
# print(N)
# N = list(input().split())
# for _ in range(len(N)):
# print(N[_])
# N = []
# for _ in range(2):
# N.append(input())
# print(N) #append๋ฅผ ์ฌ์ฉํ์ง ์๊ณ ๋์
ํ ์ ์๋ ๋ฐฉ๋ฒ์?
# N = []
# for _ in range(2):
# N = input() # ์ด๋ ๊ฒํ๋ฉด ์์ ์ list์๋ N์ ์ผ๋ฐ ๋ณ์๋ก ๋ณ๊ฒฝ๋๋ค.
# print(N) # append๋ฅผ ์ฌ์ฉํ์ง ์๊ณ ๋์
ํ ์ ์๋ ๋ฐฉ๋ฒ์?
# N = []
# for _ in range(ord('A'), ord('Z')):
# N.append(chr(_))
# for i in range(len(N)):
# print(N[i])
728x90
'๐ง Algorithm > Baekjoon๐ก' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
๐ก2908๋ฒ (0) | 2023.12.24 |
---|---|
๐กโจ์ค๊ฐ์ ๊ฒ : sort, reverse ๊ทธ๋ฆฌ๊ณ slicing (0) | 2023.12.23 |
๐ก2675๋ฒ (0) | 2023.12.23 |
๐กโจ์ค๊ฐ์ ๊ฒ : ๊ฐ์ ํ๋ณํ ๊ณผ list ๊ทธ๋ฆฌ๊ณ ๋ฌธ์์ด(str) (0) | 2023.12.23 |
๐กโจ10809๋ฒ (0) | 2023.12.23 |
Comments