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
the function does not return anything, so the result is an object without a type, you should enter
return <value, that you need>
Comments
Leave a comment