How should I go through | Sololearn: Learn to code for FREE!


How should I go through

def search(): if word in text: print("word found") else: print("word not found") text=input() word=input() search()

4/27/2021 5:23:23 AM

Akash Prasad

6 Answers

New Answer


🅰🅹 🅐🅝🅐🅝🅣 now i understand word (small letter w ) and Word(with capital letter W) is different although word is used as identifier and Word as string in print statement so it is always better to print a statement should start with capital letter please like if i interpreted 100% accurately correct


The code is okay. What's the problem? INPUT: Sololearn is cool platform. cool OUTPUT: word found


Akash Prasad If you don't pass parameter in function then you have to declared variable above the function and also there is "Word" not "word" Your code should be look like this: text = input() word = input() def search(): if word in text: print("Word found") else: print("Word not found") search()


🅰🅹 🅐🅝🅐🅝🅣 his code is also fine how and where he declared his variable. Because as you can see text and word was declared before the function call. If you print text and word inside the function search() you'll see that those variables are accessible from inside the function.


While running in code playground it is working but in submitting project its not accepting


🅰🅹 🅐🅝🅐🅝🅣 i tried it too