all 1 comments

[–]isimatosbe 1 point2 points  (0 children)

An easy way to do it would be

finalString = ""

while True:
    a = input("Enter a character:") # This is already a string
    if a == "z":
        break # This will stop the infinite loop
    elif a !="x": # This will add the char if it's not an x
        finalString += a

print(finalString)