0

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!")
trxgnyp1
  • 317
  • 1
  • 10
  • `SSL.lower() == 'http'` – furas Jun 29 '20 at 23:24
  • Does this answer your question? [Comparing a string to multiple items in Python](https://stackoverflow.com/questions/6838238/comparing-a-string-to-multiple-items-in-python) – Gino Mempin Jun 29 '20 at 23:28
  • 1
    Or `SSL in ['http', 'HTTP']` if you don't want to allow things like `hTtP` – fas Jun 29 '20 at 23:28
  • BTW: it can begood to use `strip()` to remove spaces which someone would type accidently and it may not see them on screen. `SSL.strip().lower() == 'http'` – furas Jun 30 '20 at 00:33

2 Answers2

2

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)

audiodude
  • 1,865
  • 16
  • 22
1

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!")
adamgy
  • 4,543
  • 3
  • 16
  • 31