asked
[Renewal] Python Introduction and Web Crawling Basics Bootcamp [Python, Web, and Data Understanding Fundamentals] (Updated)
Python Fundamentals You'll Naturally Master While Solving Problems: Using Strings, Lists, and Conditionals 1
Written on
·
191
0
14'05초
안녕하세요,
주민등록번호는 숫자이니까,
data=int(input())
print(data[0:2])
로도 할수 있을것 같은데 이렇게 하는 경우 에러가 나네요.
인풋을 정수로 바꾸면 슬라이싱이 되지 않는건가요?
답변 부탁드리겠습니다. 감사합니다.
Answer 1
안녕하세요.
data 타입이 int 이면, [0:2] 와 같이 슬라이싱이 되지 않습니다. 문자열에 대해서만 가능합니다.