+ 1

Guess letter in word

I have to define a function letter_in_word(guess, word) that returns True if Guess is a letter in the word and False if it is not

28th Jan 2018, 11:56 PM
Nick DiPaolo
Nick DiPaolo - avatar
5 Réponses
+ 2
thank you :)
29th Jan 2018, 2:25 AM
Nick DiPaolo
Nick DiPaolo - avatar
+ 1
def letter_in_word(guess, word): if guess in word: return True else: return False Test it: print(letter_in_word("a", "cat")) print(letter_in_word("a", "dog")) output: True False
29th Jan 2018, 1:50 AM
LordHill
LordHill - avatar
+ 1
i’m using python
29th Jan 2018, 2:05 AM
Nick DiPaolo
Nick DiPaolo - avatar
+ 1
Check my code Nick. it is in python
29th Jan 2018, 2:07 AM
LordHill
LordHill - avatar
0
which language? depending on that your string data type provides functions to search for substring(your guess) in another string(your word) in JavaScript function letter_in_word(guess, word){ return word.indexOf(guess)>-1; }
29th Jan 2018, 1:23 AM
Mauricio Martins
Mauricio Martins - avatar