Created
March 5, 2019 18:40
-
-
Save davegotz/1e5917eb56e8dfc0d91594f1a6fd61d1 to your computer and use it in GitHub Desktop.
Functions with "search in a book" example.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
def query(book): | |
query_string = input("What do you want to look for?") | |
if query_string in book: | |
print("Yes, it is in the book.") | |
else: | |
print("No, it is not in the book") | |
def main(): | |
book = ["This", "is", "my", "greatest","book","ever"] | |
book2 = ["This", "is", "my", "worst","book","ever"] | |
query(book) | |
query(book2) | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just a little suggestion, adding \n to the end of the string in the input function makes it so that the user types one line below the question. Example: