Inconsistent use of tabs and spaces in indentation

后端 未结 6 2182
猫巷女王i
猫巷女王i 2020-11-28 15:24
def contains_sequence(dna1, dna2):
    \'\'\' (str, str) -> bool

    Return True if and only if DNA sequence dna2 occurs in the DNA sequence
    dna1.

    >&         


        
6条回答
  •  日久生厌
    2020-11-28 15:44

    According to the your Doc strings

    your code:

    b=False
    len2=len(dna2)
    i=0
    for j in dna1:
        temp=dna1[i:i+len2]
        if temp == dna2:
            b=True
        i=i+1
    return b
    

    This much Big code can be simplified to one line

    return dna1.find(dna2)>=0
    

    Also if u are not good with indentations in 'vim' editor its good to practice in IDLE3

提交回复
热议问题