[Pycharm] input().split() 리스트가 제대로 안들어가는 버그

오도원공육사·2022년 9월 23일
0

IDE

목록 보기
1/3

파이참에서 인풋으로 리스트를 받는 경우 input().split()을 사용한다.
이때 인풋데이터에 대해서 리스트가 제대로 안 들어가는 버그가 발생할 때가 있다.

이상한 것은 디버그로 하면 잘 들어가는데 실행으로 하면 리스트가 비어있다.

예시)

numbers = [list(map(int, input().split())) for _ in range(3)]
print(numbers)
>> 6 5
7 5
3 4
[[], [7, 5], []]

위처럼 불규칙하게 받아지는 경우이다.

해결방법

  • 우측상단에 configuration -> Excution 탭 -> Emulate terminal in output console 활성화

  • configuration 탭에서 Edit configration templates...을 누르면 python 파일에 대한 전역설정을 할 수 있다.

참고.
https://stackoverflow.com/questions/72255982/input-split-in-loop-issues-in-pycharm
https://www.jetbrains.com/help/pycharm/run-debug-configuration.html#config-folders

profile
잘 먹고 잘살기

0개의 댓글