Harry2406 commited on
Commit
20df6cd
·
verified ·
1 Parent(s): 1a7c734

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +8 -6
src/streamlit_app.py CHANGED
@@ -49,6 +49,9 @@ weight_kg = st.number_input(
49
  format="%.2f"
50
  )
51
 
 
 
 
52
  # =========================
53
  # BMI Calculation
54
  # =========================
@@ -56,7 +59,7 @@ def calculate_bmi(height_cm, weight_kg):
56
  if height_cm > 0 and weight_kg > 0:
57
  height_m = height_cm / 100
58
  return weight_kg / (height_m ** 2)
59
- return None
60
 
61
  def bmi_category(bmi):
62
  if bmi < 18.5:
@@ -68,13 +71,12 @@ def bmi_category(bmi):
68
  else:
69
  return "Obese"
70
 
71
- bmi = calculate_bmi(height_cm, weight_kg)
72
-
73
- # Show BMI instantly when values are entered
74
- if bmi:
75
  st.info(f"Your BMI is: {bmi:.2f} ({bmi_category(bmi)})")
76
 
77
- st.markdown("---")
78
 
79
  # =========================
80
  # 2️⃣ Fitness Details
 
49
  format="%.2f"
50
  )
51
 
52
+ # =========================
53
+ # BMI Calculation
54
+ # =========================
55
  # =========================
56
  # BMI Calculation
57
  # =========================
 
59
  if height_cm > 0 and weight_kg > 0:
60
  height_m = height_cm / 100
61
  return weight_kg / (height_m ** 2)
62
+ return 0 # Always return something
63
 
64
  def bmi_category(bmi):
65
  if bmi < 18.5:
 
71
  else:
72
  return "Obese"
73
 
74
+ # ALWAYS define bmi safely
75
+ bmi = 0
76
+ if height_cm > 0 and weight_kg > 0:
77
+ bmi = calculate_bmi(height_cm, weight_kg)
78
  st.info(f"Your BMI is: {bmi:.2f} ({bmi_category(bmi)})")
79
 
 
80
 
81
  # =========================
82
  # 2️⃣ Fitness Details