i am trying to iterate though a string and check if the consecutive characters are the same. If not i want to inset a space between them. Then store this new string in the Mynewstring until the while loop goes through all characters.
I am posting a While loop, a tried this also with a For loop, to the same result. Any help will be appreciated!
mystr = '77445533'
mynewstring = ""
myind = 0
while myind < len(mystr)+1:
if mystr[myind] != mystr[myind +1]:
mynewstring = mystr[:(myind)] + " " + mystr[(myind+1):]
myind+=1
print(mynewstring)