본문 바로가기
python

"pithon" 을 "python"으로 바꾸기

by sj0020 2020. 6. 16.
>>> a = "pithon"
>>> a[1] = y
Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    a[1] = y
NameError: name 'y' is not defined
>>> a[1] = 'y'
Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    a[1] = 'y'
TypeError: 'str' object does not support item assignment
>>> a[1]
'i'
>>> a[:1] + "y" + a[2:]
'python'
>>>