Added doctest in palindrome.py (#172)

* Added doctest in palindrome.py

* small change to re run lint_python test
pull/181/head
Atin Bainada 2021-04-13 21:31:28 +05:30 committed by GitHub
parent 8793610586
commit 0a9135b5b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 5 deletions

View File

@ -1,10 +1,22 @@
#!/usr/bin/python3
# Palindrome Check Function on Python 3
# Palindrome Check Function using Python 3
# The Palindrome Algorithm
# this takes in a string and returns a boolean equal to the result of
# whether the program is a palindrome or not.
# whether the string is a palindrome or not.
string_1 = "abba"
string_2 = "abbcccbba"
string_3 = "abbccbbba"
def palindrome(s: str) -> bool:
"""
>>> palindrome(string_1)
True
>>> palindrome(string_2)
True
>>> palindrome(string_3)
False
"""
# Reverse string using idiomatic python
reversed_string = s[::-1]
# return the answer, by comparing string and its reverse
@ -22,9 +34,6 @@ def is_palindrome(s: str):
# main program
if __name__ == "__main__":
string_1 = "abba"
string_2 = "abbcccbba"
string_3 = "abbccbbba"
is_palindrome(string_1)
is_palindrome(string_2)
is_palindrome(string_3)