python 2.7 - Finding a substring within a string without using any built in functions -
i have find particular substring within string , position within string. easy have without using built in functions or methods in python. appreciate if help. thanks
string="acaagatgccattgtcccccggcctcctgctgctgctgctctccggggccacggccaccgctgccctgcccctggagggtggccccaccggccgagacagcgagcatatgcaggaagcggcaggaataaggaaaagcagcctcctgactttcctcgcttggtggtttgagtggacctcccaggccagtgccgggcccctcataggagaggaagctcgggaggtggccaggcggcaggaaggcgcacccccccagcaatccgcgcgccgggacagaatgccctgcaggaacttcttctggaagaccttctcctcctgcaaataaaacctcacccatgaatgctcacgcaagtttaattacagacctgaa"
substring='ttg'
this code work if don't want use inbuilt function.
man = "acaagatgccattgtcccccggcctcctgctgctgctgctctccggggccacggccaccgctgccctgcccc$ check = "ttg" in range (0, len(man)): if man[i]==check[0]: sum =0 j in range(0, len(check)): if man[i+j] != check[j]: break sum = 0 else: sum = sum +1 if sum == len(check): print
Comments
Post a Comment