jeudi 7 septembre 2017

Python if in - to search for a letter in a word

Exercise: Create a variable containing a word. Answer with True if the word contains the letter 'j' otherwise answer with False. Use the in operator.

word = "jump"

if word in "j": variable = True else: variable = False

I get false. What's wrong?

Aucun commentaire:

Enregistrer un commentaire