def contains_sequence(dna1, dna2):
''' (str, str) -> bool
Return True if and only if DNA sequence dna2 occurs in the DNA sequence
dna1.
>>> contains_sequence('ATCGGC', 'GG')
True
>>> contains_sequence('ATCGGC', 'GT')
False
'''
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
I am new to Python. The program pasted above gives me an error "Inconsistent use of tabs and spaces in indentation" at line "if temp == dna2:" specifically. Can someone please help me out in finding out how the indentation is incorrect?
When the code is executed, the “TabError inconsistent use of tabs and spaces in indentation”. This occurs when the code has all the tabs and spaces mixed up. To fix this, you have to ensure that the code has even indentation. Another way to fix this error is by selecting the entire code by pressing Ctrl + A.
The Python “TabError: inconsistent use of tabs and spaces in indentation” error is raised when you try to indent code using both spaces and tabs. You fix this error by sticking to either spaces or tabs in a program and replacing any tabs or spaces that do not use your preferred method of indentation.
It's not that tabs are completely bad but considering the vastness of the programming community and tools, spaces are a more standard and correct way to align and indent your code than tabs.
It means you have mixed up spaces and tabs in the indentation. You have to fix that to be consistent with either tabs or spaces.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With