Sign in
Log inSign up

My First ACTUAL Python code

M. Saeb's photo
M. Saeb
·Mar 6, 2019

this is my first time trying to write a python code that is actually usable, and although it might be too simple or maybe too messy (for a python code standards) to share, yet there nothing wrong with trying to learn your flaws at an early stage right ?😄. so I wish you guys can give some feedback on it, like how can I make it more pythonic or more professional looking ?

it's a simple program of finding a book in a specific library and knowing its genre

comedy = ["idiots","Boys", "Running"]
romance = ["lovers", "long story", "rings"]
horror = ["bells", "house", "faceless"]
Library = {"comedy": comedy, "Romance": romance, "Horror": horror}
user_input = input("please enter the books you want: ")
found = False

for genre in Library:
    for book in Library[genre]:
        if user_input == book:
            found = True
            print ("Book:", book)
            print ("Genre:", genre)
if not found:
    print ("the book was not found")
Hassle-free blogging platform that developers and teams love.
  • Docs by Hashnode
    New
  • Blogs
  • AI Markdown Editor
  • GraphQL APIs
  • Open source Starter-kit

© Hashnode 2024 — LinearBytes Inc.

Privacy PolicyTermsCode of Conduct