You are viewing a single comment's thread from:

RE: Upvote bot in less than 10 lines of code

in #steem8 years ago

Just tested this more and found out what the error was:

If you include the single quotes around the array, both statements return True

stringList = '["list","of","strings"]'
print("list" in stringList)
True
print ("li" in stringList)
True

But if you remove the single quotes around the array, it functions as intended:

stringList = ["list","of","strings"]
print("list" in stringList)
True
print ("li" in stringList)
False

Hope this helps!

Sort:  

In the first case, the stringList is actually a simple string and is not interpreted as an array. that's why the test returns true in both cases.