i'm just learning python 3 now. '''It's ask the user for two string and find the Hamming distance between the strings.Input sequences should only include nucleotides ‘A’, ’T’, ‘G’ and ‘C’. Program should ask the user to reenter the sequence if user enter an invalid character.Program should be able to compare the strings are of same length. If the strings are not of the same length program should ask the user to enter the strings again.User should be able to enter upper, lower or both cases as an input '''
The program should print the output in the following format:
please enter string one: GATTACA
please enter string two: GACTATA
GATTACA
|| || |
GACTATA
The hamming distance of sequence GATTACA and GACTATA is 2
So the Hamming distance is 2.
What I already try below, but could not get answer.
def hamming_distance(string1, string2):
string1 = input("please enter first sequence")
string2 = input("please enter second sequence")
distance = 0
L = len(string1)
for i in range(L):
if string1[i] != string2[i]:
distance += 1
return distance
string1
andstring2
as parameter then again taking input from the user. Is it what you intended to do? Can you clarify what you meant by "could not get an answer"? – Folie