0

How should I go through

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

27th Apr 2021, 5:23 AM
Akash Prasad
Akash Prasad - avatar
6 Respostas
+ 2
🅰đŸ…č 🅐🅝🅐🅝🅣 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
27th Apr 2021, 6:03 AM
Akash Prasad
Akash Prasad - avatar
+ 2
The code is okay. What's the problem? INPUT: Sololearn is cool platform. cool OUTPUT: word found
27th Apr 2021, 5:25 AM
minirkk
minirkk - avatar
+ 2
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()
27th Apr 2021, 5:50 AM
AÍąJ
AÍąJ - avatar
+ 2
🅰đŸ…č 🅐🅝🅐🅝🅣 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.
27th Apr 2021, 5:55 AM
minirkk
minirkk - avatar
+ 1
While running in code playground it is working but in submitting project its not accepting
27th Apr 2021, 5:48 AM
Akash Prasad
Akash Prasad - avatar
28th Apr 2021, 3:37 PM
Akash Prasad
Akash Prasad - avatar