I'm currently trying to make a very simply testing function that first checks to see if the users input is a multiple of 3, then tests each individual character to see if they are valid characters. Here's my code below:
def is_dna(string):
string.upper()
if(len(string) % 3 == 0):
print("LENGTH CORRECT")
for n in string:
if(n == "A" or n == "T" or n == "C" or n == "G"):
print("Valid")
else:
print("Invalid character")
break
return True
else:
print("Too many/little characters")
return False
When run, the bottom section will run fine, and if a correct amount of characters is used this will also successfully print the debug "LENGTH CORRECT" string. The issue is that the for loop will not initialize, and I haven't the foggiest why. Testing just the loop shows it to work fine; what is wrong with this function?