Created
January 30, 2019 15:13
-
-
Save Ojha-Shashikant/9a4b5cf19e5f111e01358f2d4083bea3 to your computer and use it in GitHub Desktop.
To check Palindrome status.
This file contains 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
def test_suite(test_inputs): | |
for tst, exp in test_inputs.items(): | |
actual = check_palindrome(tst) | |
if actual == exp: | |
print("OK") | |
else: | |
print("NOK") | |
def check_palindrome(string): | |
""" | |
This checks if the given input string is a palindrome | |
It returns True if the input string is a palindrome | |
It returns False if the input string is not a palindrome | |
""" | |
# Your code goes here | |
reversed_string = string[::-1] | |
if reversed_string == string: | |
return True # to indicate that the input string is a palindrome | |
else: | |
return False | |
# Main test cases | |
if __name__ == '__main__': | |
test_inputs = \ | |
{ | |
"radar" : True, # test string : expected status | |
"panama" : False, | |
"Madman" : False, | |
"TCATGAACGTCTTCTGCAAGTACT" : True, | |
"GACATACTCCTCCACCTCATACAG" : False, | |
} | |
test_suite(test_inputs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment