After a user enters a string of digits, the Python code is to replace the 5 with a 0, but I have not been able to overcome errors in syntax. I tried reading the reference on if statements but was unable to identify the issue. Thank you.
string = input('Enter a string of digits: ')
length_of_string = len(string)
counter = 0
while (counter <= length_of_string):
{
if string[counter] == '5':
string[counter] = '0'
counter = counter + 1
else:
counter = counter + 1
continue
}
File "<ipython-input-37-154bb43ba751>", line 15
if string[counter] == '5':
^
SyntaxError: invalid syntax