[Solved] Check if a string has space between all its letters [closed]


This is very crude and it is unclear what you want:

s1 = "t his will fail"
s2 = "t h     i s s e p a d"

def is_spaced(s):
    prev = s[0]
    result = "is spaced"
    for c in s[1:]:
        if not c.isspace() and not prev.isspace():
            result = "not spaced"
            break
        prev = c

    return result

print(is_spaced(s1))
print(is_spaced(s2))

Outputs:

not spaced
is spaced

1

solved Check if a string has space between all its letters [closed]