How this variable declaration and if statement works? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How this variable declaration and if statement works?

text = input() word = input() def search(text, word): search = word and text if word in text == search: return "Word found" else: return "Word not found" print(search(text,word)) https://code.sololearn.com/cS932OrcaT03/?ref=app

26th Sep 2022, 4:55 PM
Hafsa Mahmood
2 Answers
+ 2
There is unnecessary extra variable using 'search'. Remove it. It will be clear code.
26th Sep 2022, 5:40 PM
Jayakrishna 🇮🇳
+ 1
Also, you have a function and a variable with the same name: "search". Always use unique names.
27th Sep 2022, 3:21 AM
Emerson Prado
Emerson Prado - avatar