\' \' in word == True
I\'m writing a program that checks whether the string is a single word. Why doesn\'t this work and is there any better way to che
You can say word.strip(" ")
to remove any leading/trailing spaces from the string - you should do that before your if
statement. That way if someone enters input such as " test "
your program will still work.
That said, if " " in word:
will determine if a string contains any spaces. If that does not working, can you please provide more information?