Jan-20-2021, 10:22 PM
(This post was last modified: Jan-20-2021, 10:22 PM by BashBedlam.)
You are updating pos a little too early. When you add one to pos outside of the if statement then your code works as expected.
newstring ="" string = input("Enter a string: ") pos = 0 length = len(string) while (pos<length): if (string[pos].isspace()!=True): newstring = newstring + string[pos] pos += 1 print(newstring)