Palindrome

    0

    0

    Aakanksha Priya

    Check whether the given string is a palindrome or not

    def isPalindrome(str):
        # Run loop from 0 to len/2
        for i in range(0, int(len(str)/2)):
            if str[i] != str[len(str)-i-1]:
                return False
        return True
    # main function
    s = input("Enter the string: ")
    ans = isPalindrome(s)
    if (ans):
        print("Yes, the given string is a palindrome.")
    else:
        print("No, the given string is not a palindrome.")
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Explore
    • Cookbooks
    • Playground
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.