- 1
What is the right code lines ? Can you help me?
You’re working on a search engine. Watch your back Google! The given code takes a text and a word as input and passes them to a function called search(). The search() function should return "Word found" if the word is present in the text, or "Word not found", if it’s not. Sample Input "This is awesome" "awesome" Sample Output Word found Define the search() function, so that the given code works as expected. Here are the codes given to us text = input() word = input() print(search(text, word))
5 odpowiedzi
+ 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))
+ 3
Ökkeş Sefa Coşkun
Make a function and check if word exist in text then print 'Word found' if not exist then 'Word not found'
+ 1
Thank a lot for your help
0
I need your help with something
I couldn't find the result of this problem even though I tried many times
0
You have been asked to make a special book categorization program, which assigns each book a special code based on its title.
The code is equal to the first letter of the book, followed by the number of characters in the title.
For example, for the book "Harry Potter", the code would be: H12, as it contains 12 characters (including the space).
You are provided a books.txt file, which includes the book titles, each one written on a separate line.
Read the title one by one and output the code for each book on a separate line.
For example, if the books.txt file contains:
Some book
Another book
Your program should output:
S9
A12
Recall the readlines() method, which returns a list containing the lines of the file.
Also, remember that all lines, except the last one, contain a \n at the end, which should not be included in the character count.
file = open("/usercode/files/books.txt", "r")
#your code goes here
file.close()