Algorithm

[python]숫자를 받아서 리스트로 변환하는 법

soduddl1 2020. 12. 1. 21:53
코테공부를 하면서 새롭게 알게된 내용에 대하여 기록하고 있습니다.

 

1.int로 받은 후 map을 이용해서 list로 변환

num=int(input())
num=list(map(int,str(num))

int로 받은 후 str로 변환 후 list처리해주기

 

- str처리를 해주지 않으면 TypeError: 'int' object is not iterable 에러 발생

- 문자열도 인덱스로 접근이 가능하지만 스택으로 사용이 불가능,,!