jeudi 10 septembre 2020

Finding a string in another input string in Python [closed]

Create a basic function that returns True if the word 'dog' is contained in the input string. Don't worry about edge cases like a punctuation being attached to the word dog, but do account for capitalization.

I have written the following code

def finddog(s):
    for i in range(len(s)):
        if s[i:i+3] == "dog":
                return True

This code when executed shows following error in Jupyter Notebook :

SyntaxError: EOL while scanning string literal

What is wrong with my code?

Aucun commentaire:

Enregistrer un commentaire