Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- # Filename: is_palindrome.py
- # Author: Jeoi Reqi
- """
- Is Palindrome Script
- This script checks whether a user-input string is a palindrome or not.
- It utilizes a function, is_palindrome, to perform the palindrome check.
- Requirements:
- - Python 3
- Usage:
- 1. Run the script.
- 2. Enter a string when prompted.
- 3. The script will display whether the entered string is a palindrome or not.
- """
- def is_palindrome(string):
- """Check if string is a Palindrome.
- Args:
- string (str): String.
- Returns:
- bool: True if string is a palindrome, False otherwise.
- """
- string = string.strip()
- return string == string[::-1]
- def main():
- # Get user input
- user_input = input("Enter a string: ")
- # Check if the input is a palindrome
- result = is_palindrome(user_input)
- # Display the result
- if result:
- print(f"The entered string '{user_input}' is a palindrome.")
- else:
- print(f"The entered string '{user_input}' is not a palindrome.")
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement