Skip to content

Commit 03a9716

Browse files
committed
Simple letter counter app to the gui based app
1 parent 96b6db4 commit 03a9716

File tree

1 file changed

+24
-17
lines changed

1 file changed

+24
-17
lines changed

Letter_Counter.py

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
1-
# Letter Counter App
1+
import tkinter as tk
2+
root = tk.Tk()
3+
root.geometry("400x260+50+50")
4+
root.title("Welcome to Letter Counter App")
5+
message1 = tk.StringVar()
6+
Letter1 = tk.StringVar()
7+
def printt():
8+
message=message1.get()
9+
letter=Letter1.get()
10+
message = message.lower()
11+
letter = letter.lower()
212

3-
print("Hey there! Welcome to the Letter Counter App")
13+
# Get the count and display results.
14+
letter_count = message.count(letter)
15+
a = "your message has " + str(letter_count) + " " + letter + "'s in it."
16+
labl = tk.Label(root,text=a,font=('arial',15),fg='black').place(x=10,y=220)
17+
lbl = tk.Label(root,text="Enter the Message--",font=('Ubuntu',15),fg='black').place(x=10,y=10)
18+
lbl1 = tk.Label(root,text="Enter the Letter you want to count--",font=('Ubuntu',15),fg='black').place(x=10,y=80)
19+
E1= tk.Entry(root,font=("arial",15),textvariable=message1,bg="white",fg="black").place(x=10,y=40,height=40,width=340)
20+
E2= tk.Entry(root,font=("arial",15),textvariable=Letter1,bg="white",fg="black").place(x=10,y=120,height=40,width=340)
21+
but = tk.Button(root,text="Check",command=printt,cursor="hand2",font=("Times new roman",30),fg="white",bg="black").place(x=10,y=170,height=40,width=380)
22+
# print("In this app, I will count the number of times that a specific letter occurs in a message.")
23+
# message = input("\nPlease enter a message: ")
24+
# letter = input("Which letter would you like to count the occurrences of?: ")
425

5-
# Get user input.
6-
name = input("\nWhat is your name: ").title().strip()
7-
print("Hello, " + name + "!")
8-
9-
print("In this app, I will count the number of times that a specific letter occurs in a message.")
10-
message = input("\nPlease enter a message: ")
11-
letter = input("Which letter would you like to count the occurrences of?: ")
12-
13-
# Standardize to lower case.
14-
message = message.lower()
15-
letter = letter.lower()
16-
17-
# Get the count and display results.
18-
letter_count = message.count(letter)
19-
print("\n" + name + ", your message has " + str(letter_count) + " " + letter + "'s in it.")
26+
root.mainloop()

0 commit comments

Comments
 (0)