20240201 이것이 코딩 테스트다 챕터4(구현)
input().split()
한 줄에 공백을 기준으로 여러개의 문자가 주어지고, 그것을 하나의 리스트로 저장하고 싶을때, list(input().split())하지 않고 그냥 input().split()만 해도 된다.
str_list1 = list(input().split())
print(str_list1)
str_list2 = input().split()
print(str_list2)
## 입력
# a b c d e
## 출력
# ['a', 'b', 'c', 'd', 'e']
## 입력
# a b c d e
## 출력
# ['a', 'b', 'c', 'd', 'e']
하지만 여러개의 숫자가 주어질 때는 list(map(int, input().split()))해줘야 한다. 그냥 map(int, input().split())하면 에러 남.
Today : 이것이 코딩 테스트다 104 ~ 112pg
Leave a comment