trxgnyp1
trxgnyp1

Reputation: 428

How can I check if a var is one of 2 strings in python?

in this code, I want to check if the user typed the URL with "http" in it and after that, check if the SSL var is http or https, but I want it to ignore the caps (http or HTTP)

SSL = input(" Does your site have (http) or (https)? >> ")
URL = input(" Your URL >> ")
if "http" not in URL:
    if SSL == "http":  # I want SSL to be http or HTTP
        print("I work!")

Upvotes: 0

Views: 46

Answers (2)

adamgy
adamgy

Reputation: 5613

Use the lower() method:

SSL = input(" Does your site have (http) or (https)? >> ")
URL = input(" Your URL >> ")
if "http" not in URL:
    if SSL.lower() == "http":  # I want SSL to be http or HTTP
        print("I work!")

Upvotes: 1

audiodude
audiodude

Reputation: 2790

Try:

if SSL in ('http', 'HTTP'):

for arbitrary lists of values or

if SSL.lower() == 'http':

for case insensitivity (but note that "hTTp" will also match in this case)

Upvotes: 2

Related Questions