#python #anaconda #jupyter-notebook #visual-code #html #css #javascript #http 제목Python에서는 C/C++처럼 문자열에 [i]로 값을 줄수 없어요.2019-04-06 22:49작성자drsungwon 1. Python에서의 String은 immutable, 즉 수정이 불가능합니다. 아래는 이에 대한 python.org의 내용입니다.Python strings cannot be changed — they are immutable. Therefore, assigning to an indexed position in the string results in an error:>>>>>> word[0] = 'J' Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'str' object does not support item assignment >>> word[2:] = 'py' Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'str' object does not support item assignment If you need a different string, you should create a new one:>>>>>> 'J' + word[1:] 'Jython' >>> word[:2] + 'py' 'Pypy' 2. 따라서, 아래와 같은 형태로 해야 하는 것이지요.def reverseString(strr): b = strr[4] b += strr[3] b += strr[2] b += strr[1] b += strr[0] return bprint( reverseString("Hello") ) 목록답변글쓰기 댓글 [1] 댓글작성자(*)비밀번호(*)내용(*) 댓글 등록 더보기이전문자열 뒤집기 질문pypy2019-04-06다음VSC 돌아가는건가요?VSC2019-04-06 Powered by MangBoard | 워드프레스 쇼핑몰 망보드