-1

I have a big set of strings in Python.

Example:

url="CVE-2020-7211,https://gitlab.freedesktop.org/slirp/libslirp/commit/14ec36e107a8c9af7d0a80c3571fe39b291ff1d4"
url="CVE-2020-5204,https://github.com/troglobit/uftpd/commit/0fb2c031ce0ace07cc19cd2cb2143c4b5a63c9dd"
url="CVE-2020-7039,https://gitlab.freedesktop.org/slirp/libslirp/commit/2655fffed7a9e765bcb4701dd876e9dab975f289"
url="CVE-2020-7039,https://gitlab.freedesktop.org/slirp/libslirp/commit/82ebe9c370a0e2970fb5695aa19aa5214a6a1c80"

I need to select those that include https://github.com/ and /commit/

my code:

if ("https://github.com/" and "/commit/") in url:
        print("OK")
else:
        print("not okay")

This code matches all of the 4 cases in the example above. I need it to match the second url only.

How should I do it?

Chelsea-fc
  • 145
  • 7

1 Answers1

0

You can't use and like that, you need to separate statements:

if "https://github.com/" in url and "/commit/" in url:
    print("OK")
else:
    print("not okay")
U13-Forward
  • 69,221
  • 14
  • 89
  • 114