4 Antworten
+ 2
Had the if else statementa but I hadn't used the split function 🤦. Thank you
+ 2
text = input()
word = input()
def search(text, word ):
if word in text:
return "Word found"
else:
return "Word not found"
print(search(text, word))
+ 1
All you need to do is make a function
Function goes like this
def search(text, word):
# 1
# 2
# 3
# 4
# 5
1. In the first line, you're gonna want to split the text variable using the built-in function split(). The split function will split the string to a list.
Example :
x = "I ate a banana"
print(x.split())
Output : ["I", "ate", "a", "banana"]
2-5. Here, you will want to use the if else statements. You should know how to check if an element is in a string considering you went that far in the lesson so I'll leave this one to you
Refer to lesson 31.1 if you're having trouble with 2-5
Hope this helps, happy coding!
0
Hold on