TypeError: 'str' object does not support item assignment
I am taking a 11 digit number as input in recieved_code
, later on after getting the error position, I want to replace that digit with 0 or 1 depending on the condition.
recieved_code = (input())
#Detecting the position of error
parList = parList[: : -1]
error = 0
for i in range(0,len(parList)):
error = error + pow(2,i)*parList[i]
print("\nError is at position:",error)
#Correcting the error
if recieved_code[error-1] == 1:
print("It's 1")
recieved_code[error-1] = 0
else:
print("It's 0")
recieved_code[error-1] = 1
print("Corrected code:",recieved_code)
I wanted 0 to be replaced by 1, or 1 to be replaced by 0.