VirtualOasis commited on
Commit
f4892cf
·
verified ·
1 Parent(s): 7a854bb

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ def letter_counter(word, letter):
4
+ """
5
+ Count the number of occurrences of a letter in a word or text.
6
+ Args:
7
+ word (str): The input text to search through
8
+ letter (str): The letter to search for
9
+ Returns:
10
+ str: A message indicating how many times the letter appears
11
+ """
12
+ word = word.lower()
13
+ letter = letter.lower()
14
+ count = word.count(letter)
15
+ return count
16
+
17
+ demo = gr.Interface(
18
+ fn=letter_counter,
19
+ inputs=[gr.Textbox("strawberry"), gr.Textbox("r")],
20
+ outputs=[gr.Number()],
21
+ title="Letter Counter",
22
+ description="Enter text and a letter to count how many times the letter appears in the text."
23
+ )
24
+
25
+ if __name__ == "__main__":
26
+ demo.launch(mcp_server=True)