Aug-25-2020, 11:50 AM
Hi,
I'm currently coding a DNA to RNA translator and I'd like to make some exceptions with the try and except key.
The first exception I'm doing is if in the phrase the user inputs there aren't the letters I stated, it should notify an error. However, it's not doing that.
Here's the code
I'm currently coding a DNA to RNA translator and I'd like to make some exceptions with the try and except key.
The first exception I'm doing is if in the phrase the user inputs there aren't the letters I stated, it should notify an error. However, it's not doing that.
Here's the code
try: def translate(phrase): translation = "" for letter in phrase: if letter.lower() in "a": if letter.isupper: translation = translation + "U" else: translation = translation + "u" elif letter.lower() in "t": if letter.isupper: translation = translation + "A" else: translation = translation + "a" elif letter.lower() in "c": if letter.isupper: translation = translation + "G" else: translation = translation + "g" elif letter.lower() in "g": if letter.isupper: translation = translation + "C" else: translation = translation + "c" return translation except SyntaxError: def translate(phrase): for letter in phrase: if letter.lower() in "bdefhijklmnopqrsvwxyz": print("DNA CHAIN INCORRECT") print(translate(input("Enter your DNA chain:")))