Skip to content
Advertisement

Searching for a keyword, inputted by the user using sqlite3 and python 3.7

I want to search for a post using the keyword inputted from the user in python 3.7, I came up with two solutions but none worked, here’s what I did.

Possible solution 1:

However, it gives me this error

Possible solution 2:

This time returns an empty list, I tried hardcoding a value using the normal method:

and it did return the desired values, so the code should output a result.

Advertisement

Answer

Try:

In your case, you can also use instr which return the index of the substring you’re searching for (0 otherwise):

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement