Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4c36a4c

Browse files
Merge pull request avinashkranjan#2167 from Abhishek-Rajput-81/master
Palindrome Checker
2 parents f3bfdca + f80ea8f commit 4c36a4c

File tree

3 files changed

+70
-0
lines changed

3 files changed

+70
-0
lines changed

‎Palindrome Checker/README.md‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# **Palindrome Checker**
2+
This is a Python program that checks whether a given word or phrase is a palindrome or not. It provides a graphical user interface (GUI) using the Tkinter library.
3+
4+
## **Requirements**
5+
- Tkinter library
6+
7+
## **How to Run**
8+
1. Install the Tkinter library if it is not already installed by using
9+
```
10+
pip install tkinter
11+
```
12+
2. Open a terminal or command prompt and navigate to the directory where the file is saved.
13+
14+
3. Run the code.The GUI window will appear.
15+
16+
6. Enter a word or phrase in the input field.
17+
18+
5. Click the "Check" button to check if it is a palindrome or not.
19+
20+
6. The program will display the result in the output label below the button.
21+
22+
## **Output**
23+
![Output](image.png)
24+
25+
## **Author**
26+
[Abhishek-Rajput-81](https://github.com/Abhishek-Rajput-81)

‎Palindrome Checker/image.png‎

7.98 KB
Loading[フレーム]

‎Palindrome Checker/main.py‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import tkinter as tk
2+
from tkinter import ttk
3+
4+
def is_palindrome(word):
5+
word = word.lower()
6+
word = ''.join(char for char in word if char.isalnum())
7+
return word == word[::-1]
8+
9+
def check_palindrome():
10+
input_text = entry.get()
11+
result = is_palindrome(input_text)
12+
if result:
13+
output_label.config(text="It's a palindrome!", foreground='green',font=('Arial', 14, 'bold'))
14+
else:
15+
output_label.config(text="It's not a palindrome.", foreground='red',font=('Arial', 14, 'bold'))
16+
17+
# Create the main window
18+
window = tk.Tk()
19+
window.title("Palindrome Checker")
20+
window.geometry("350x200")
21+
window.configure(bg='white')
22+
23+
# Create style for the interface
24+
style = ttk.Style()
25+
style.configure('TLabel', font=('Arial', 12), foreground='black', background='white')
26+
style.configure('TEntry', font=('Arial', 10))
27+
style.configure('TButton', font=('Arial', 10, 'bold'))
28+
29+
# Create GUI elements
30+
display_label = ttk.Label(window, text="Enter a word or phrase:", font=('Arial', 14, 'bold'))
31+
display_label.pack(pady=10)
32+
33+
entry = ttk.Entry(window)
34+
entry.pack(padx=10)
35+
36+
check_button = ttk.Button(window, text="Check", command=check_palindrome)
37+
check_button.pack(pady=10)
38+
39+
output_label = ttk.Label(window, text="", font=('Arial', 14, 'bold'))
40+
output_label.pack(pady=10)
41+
42+
window.configure(bg='white')
43+
window.mainloop()
44+

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /