Inconsistent use of tabs and spaces in indentation

后端 未结 6 2185
猫巷女王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条回答
  •  旧时难觅i
    2020-11-28 15:49

    If you look carefully at the lines

        temp=dna1[i:i+len2]
        if temp == dna2:
    

    in your code, you will see that the "space" at the beginning of each line is "constructed" differently. In one case it uses tabs and in the other spaces, or, if both have tabs and spaces then they are used in different combinations.

    You can examine this by placing your cursor at the beginning of each line and using the right-arrow key to "walk" your way through the characters. You'll see that the cursor moves differently on each line.

    To fix, delete the tabs and spaces at the beginning of each line and re-insert them with the same characters on each line.

    To avoid in the future, train yourself to use only the tab key OR the space key to indent, and consider setting your editor to automatically convert tabs to spaces.

提交回复
热议问题