Answer to Question #177223 in Python for CLASH CODER

Question #177223

from Question #176919

REG = 'AATAA,ATTAAA,TATA,CAT,ATAGTCGC'

def find_reg(random_string_gen, reg = REG):

res = []

with open("random_string_gen.txt", 'r') as f:

text = f.read()

size = len(text) - len(reg)

for i in range(size):

for j in reg:

if text[i] != j:

break

else:

res.append([i,i+len(reg)])

file = input('Enter path and file name: ')

result = find_reg(file)

print('The pattern was found in the following positions [start, end]')

for i in result:

print(i)

what error I made

while compiling

python function3.py

The pattern was found in the following positions [start, end]

Traceback (most recent call last):

 File "function3.py", line 22, in <module>

  for i in result:

TypeError: 'NoneType' object is not iterable


1
Expert's answer
2021-03-31T12:42:54-0400

the function does not return anything, so the result is an object without a type, you should enter

return <value, that you need>

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS