bsc

Comprehensive codebase and coursework for the 4-year B.Sc. Computer Science Honours degree (WBSU)

git clone https://github.com/notamitgamer/bsc.git
· rebuilt hourlyOpen on GitHub
root / semester_2 / python / sec_7.py

sec_7.py (422B)


      1 # Function to check palindrome
      2 def is_palindrome(text):
      3     # Convert to lowercase for case-insensitive comparison
      4     text = text.lower()
      5     # Reverse the string and compare
      6     if text == text[::-1]:
      7         return True
      8     else:
      9         return False
     10 
     11 # Main program
     12 string = input("Enter a string: ")
     13 if is_palindrome(string):
     14     print(f'"{string}" is a Palindrome')
     15 else:
     16     print(f'"{string}" is not a Palindrome')