ISSUE09 :: Python ‘str’ object does not support item assignment solution
Python ‘str’ object does not support item assignment solution
String immutable 하기 때문에 변경할 수 없습니다.
An Example Scenario
string = "aaaa"
string[0] = "b"
이런 상황에서 발생하게 됩니다.
따라서, replace_string = "" 을 생성하고
The Solution
string = "aaaa"
replace_string = ""
for i in range(len(string)) :
if i==0 :
replace_string+="b"
else :
replace_string+=string[i]
print(replace_string)
이런식으로 사용합니다.
Conclusion
String은 변경할 수 없기 때문에 새로운 String 변수를 생성해서 코딩하는것이 좋습니다.
'Toy-Project > ISSUE' 카테고리의 다른 글
댓글
이 글 공유하기
다른 글
-
ISSUE11 :: google.api_core.exceptions.DeadlineExceeded: 504 Deadline Exceeded
ISSUE11 :: google.api_core.exceptions.DeadlineExceeded: 504 Deadline Exceeded
2020.08.20 -
ISSUE10 :: line 91, in finish_bundle NameError: name 'beam' is not defined During handling of the above exception, another exception occurred:
ISSUE10 :: line 91, in finish_bundle NameError: name 'beam' is not defined During handling of the above exception, another exception occurred:
2020.08.14 -
ISSUE09 :: Cannot access field name on a value with type ARRAY<STRUCT<name STRING, bytes INT64>> at [1:17]
ISSUE09 :: Cannot access field name on a value with type ARRAY<STRUCT<name STRING, bytes INT64>> at [1:17]
2020.08.11 -
ISSUE08 :: python3 equivalent for auto tuple unpacking in lambda 이슈 발생 시
ISSUE08 :: python3 equivalent for auto tuple unpacking in lambda 이슈 발생 시
2020.08.10