Use of an inefficient or incorrect API
If there are multiple APIs available to perform similar action, choose the most specialised and efficient one. This helps make your code more readable and easier to understand.
def compare_strings_noncompliant():
    samplestring1 = "samplestring1"
    samplestring2 = "samplestring"
    # Noncompliant: uses find() but ignores the returned position
    # when nonnegative.
    if samplestring1.find(samplestring2) != -1:
        print("String match found.")
    else:
        print("String match not found.")
def compare_strings_compliant():
    samplestring1 = "samplestring1"
    samplestring2 = "samplestring"
    # Compliant: uses the in operator to test for presence.
    if samplestring1 in samplestring2:
        print("String match found.")
    else:
        print("String match not found.")