Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Verify string exists as key or value in Python dictionary?

Jason GardnerJason Gardner Member Posts: 1

I'm building a scraper/crawler for linux directories. in essence the program will take users input for startpoint (EX: /home/user/Pictures/) and endpoint (EX: /home/user/Pictures/) as well as a file type to scrape for (which is where my question comes in)
I'm storing acceptable file extension types in a dictionary w/ nested lists for example:

file_types = {'audio': ['mp3', 'mpa'], 'images': ['png', 'jpg']}

then obviously i would store the user input like so:

scrape_type = input("Please enter The extension youd like scraped: \n")

how would I validate that the string stored from users input exists as a either a key ('audio' or 'images' ) or as a value of any of the dictionaries keys

Tagged:
Sign In or Register to comment.