ShahadFawaz99 commited on
Commit
5a7d26a
1 Parent(s): cbc9feb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -1,10 +1,13 @@
1
  import gradio as gr
2
 
3
  def convert_to_fahrenheit(celsius):
4
-
5
- fahrenheit = celsius * 9/5 + 32
6
- return f"{fahrenheit} °F"
7
-
 
 
 
8
  demo = gr.Interface(fn=convert_to_fahrenheit, inputs="text", outputs="text")
9
 
10
  demo.launch()
 
1
  import gradio as gr
2
 
3
  def convert_to_fahrenheit(celsius):
4
+ try:
5
+ celsius = float(celsius)
6
+ fahrenheit = celsius * 9/5 + 32
7
+ return f"{fahrenheit} °F"
8
+ except ValueError:
9
+ return "Please enter a valid number."
10
+
11
  demo = gr.Interface(fn=convert_to_fahrenheit, inputs="text", outputs="text")
12
 
13
  demo.launch()