0
Please I need the solution
You're developing a program to search for a specific book in a list of books when the book is found, then the search should stand immediately A. Use break statement to achieve this B. Consider your list as ["minor image","same birds ",'1984', "prejudice alliance", "the breaker"] C. Search for book'1984' then there to 19
4 Answers
+ 3
You already completed the Python Core course, that should be sufficient to come up with a solution with the first requirement, assuming requirement C is to print the book name.
It would be best if you can show your attempt or flow of thinking, which can help us to help you better.
+ 3
Hayatu Ashiru I don't know what (if any) output you need to print,
But remember the break statement stops a loop (for or while) immediately.
+ 3
Hayatu Ashiru ,
a hint how some steps of the task could be done:
> to do a search in a list of `strings`, we need to iterate over the elements of that list. this can be done with a loop. the loop takes each element at a time and stores it in a loop variable.
> check if the value we are searching for (`1984`) is a part of the loop variable. to do so, we can use the membership operator `in`.
> it the search was successful, we can leave the loop immediately by using the `break` statement.
> ...
+ 1
Thank you Sir