I have seen this question as a duplicate (seems all my questions have been duplicates so far)
My code
#UAA + UAG + UGA = STOP
n = 3
xdict = {
"Phenylalanine": ["UUU", "UUC"],
"Leucine": ["UUA", "CUU", "CUC", "CUA", "CUG", "UUG"],
"Isoleucine": ["AUU", "AUC", "AUA"],
"Methionine": "AUG",
"Valine": ["GUU", "GUC", "GUA", "GUG"],
"Serine": ["UCU", "UCC", "UCA", "UCG"],
"Proline": ["CCU", "CCC", "CCA", "CCG"],
"Threonine": ["ACU", "ACC", "ACA", "ACG"],
"Alanine": ["GCU", "GCC", "GCA", "GCG"],
"Tyrosine": ["UAU", "UAC"],
"Histidine": ["CAU", "CAC"],
"Glutamine": ["CAA", "CAG"],
"Asparagine": ["AAU", "AAC"],
"Lysine": ["AAA", "AAG"],
"Asparatic Acid": ["GAU", "GAC"],
"Glutamic Acid": ["GAA", "GAG"],
"Cysteine": ["UGU", "UGC"],
"Trytophan": "UGG",
"Arginine": ["CGU", "CGC", "CGA", "CGG", "AGG", "AGA"],
"Serine": ["AGU", "AGC"],
"Glycine": ["GGU", "GGC", "GGA", "GGG"]
}
lookup_dict = {k: key for key, values in xdict.items() for k in values}
a = input("Enter your DNA sequence: ")
a = a.upper()
print("Your DNA sequence is", a)
str(a)
RNA = a.replace("C", "G")
RNA = a.replace("A", "U")
RNA = a.replace("T", "A")
print("Your RNA strand is", RNA)
b = len(a)
if b % 3 == 0:
for k in [a[i:i + n] for i in range(0, len(a), n)]:
if k in xdict.values(): #checking from other question
print(lookup_dict[k], end=" ")
elif k not in xdict.values(): #checking from other question
print("I hate u")
elif b % 3 != 0:
print("Try again.")
I have tried the answer from this link and it doesn't work for me. How do I detect if a value is in a dictionary in python?