I think this code should be break. positon of "c" in string "abc" is -1, so it should break, but why didn't?
string = "abc"
print(string[-1])
while True:
position = string.find("c")
if position == -1:
break
string = string[:position] + "f" + string[position+len("c"):]
print(string)
I think this code should be break. positon of "c" in string "abc" is -1, so it should break, but why didn't?