Answer the question
In order to leave comments, you need to log in
Why is there a "'str' object attribute 'replace' is read-only'" error?
Maybe I'm just stupid, I apologize in advance)
code:
number=input('Введите номер телефона:')
if len(number)==11 and number.isdigit():
number.replace=str(number.replace)
number.replace=number.replace(number[0:7],'*')
print(number.replace)
Введите номер телефона:89143434299
Traceback (most recent call last):
File "d:\python\test.py", line 3, in <module>
number.replace=str(number.replace)
AttributeError: 'str' object attribute 'replace' is read-only
Answer the question
In order to leave comments, you need to log in
number=input('Введите номер телефона:')
if len(number)==11 and number.isdigit():
number=number.replace(number[0:7],'*')
print(number)
I can’t even imagine what forced you to try to assign its string representation to a method.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question