Which answer is correct?

There are By the editor 5e26f2036c893751405913.jpeg
Provided response -> bb
I wrote a code in Python that solves the problem similarly.
string = "a" * 50

while "aaaa" in string or "bbbb" in the string:
 if "aaaa" in the string:
 string = string.replace("aaaa","bb",1)
 string = string.replace("bbbb","aa",1)

My code gives the answer -> aabbaa

Tell me, maybe I did something wrong, or the answer to this problem wrong?
April 4th 20 at 13:11
1 answer
April 4th 20 at 13:13
With your code everything is fine, except that it is not recommended to use the word string to a variable, because Python has such a module.

Find more questions by tags Python