' ' 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 check if a string has no spaces/is a single word..
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
==takes precedence overin, so you’re actually testingword == True.But you don’t need
== Trueat all.ifrequires [something that evalutes to True or False] and' ' in wordwill evalute to true or false. So,if ' ' in word: ...is just fine: