Skip to content

Instantly share code, notes, and snippets.

@Ojha-Shashikant
Created January 30, 2019 15:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ojha-Shashikant/9a4b5cf19e5f111e01358f2d4083bea3 to your computer and use it in GitHub Desktop.
Save Ojha-Shashikant/9a4b5cf19e5f111e01358f2d4083bea3 to your computer and use it in GitHub Desktop.
To check Palindrome status.
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