pythonexcelxlrdxlwtnessus

Python ignoring %s placeholder


I'm trying to check if information is in a dictionary, and if so write to an Excel spreadsheet. However, the information I am checking for is subjective. I've tried using %s as a place holder but Python seems to ignore it, or believes the statement isn't true. No syntax errors come up. Can someone point me in the right direction of what I'm doing wrong?

I've tried using %d, but it ignored that as well. I was using a list before and switched to a dictionary, but that did not remedy the problem. If I specify a specific number it works, but not wight he placeholder %s.


Solution

  • The answer is very basic "because there is no such syntax in python"

    if "%s" in X:
        foo()
    

    simply means "do foo() if the string '%s' is an element of collection X". So if

    X = [ '%s', 'koala', 100 ]
    

    then it will be true, but it has nothing to do with "placeholder" meaning of %s.