So let's I ask a user for input like this:
url = input('enter URL: ')
parsed_url = urlparse(url).path
>>>>>>>>> /yellow/orange/blue
I only want to check to see if the first value in parsed_url, '/yellow/' exists or not. What would be the best way of going about this?
Assuming that you have something like
from urllib.parse import urlparse(meaning thatparsed_urlis just astr), you can simply doTo be clear,
str.startswith()will check if the very first thing in the path is'/yellow/'. If you want to allow cases like' /yellow/...'or:/yellow/...or whatever, the code has to be more involved.