Created
September 8, 2018 16:37
-
-
Save stephaniemdavis/cd243a402899ff0d2bb82910e1c12a38 to your computer and use it in GitHub Desktop.
Reusable code for Codewars DNA code challenges
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# iterating a string and comparing it to dictionary values | |
# by adding the result variable, I eliminate redundant and costly printing, which is the PYTHONIC way to develop | |
d = {'A':'T','T':'A','C':'G','G':'C'} | |
for k in random_string: | |
if k not in d: | |
result = '{} is not valid. {} is the culprit!'.format(random_string,k) | |
break | |
else: | |
result = 'the string is alright.' | |
print(result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment