0

I'm getting an error while running the code

#script to calculate the BMI of a person

print ("Enter your heights in meters")
height = float(raw_input())
print ("Enter your Weight in Kilograms")
weight = float(raw_input())

BMI = weight/(height*height)

print (BMI)
roganjosh
  • 12,594
  • 4
  • 29
  • 46
Debajit
  • 27
  • 7
  • What is the error? – roganjosh Jan 26 '19 at 10:39
  • Enter your heights in meters Traceback (most recent call last): File "E:\Project 64\Working With Python\BMI Calculator.py", line 4, in height = float(raw_input()) NameError: name 'raw_input' is not defined – Debajit Jan 26 '19 at 10:40
  • Because you're running in Python 3, not 2.7. `raw_input` no longer exists. Change to `input()` – roganjosh Jan 26 '19 at 10:40
  • I have used `input()` also but still, it shows error – Debajit Jan 26 '19 at 10:43
  • 1
    Please get into the habit of actually telling us what the errors _are_ rather than us having to ask you for them – roganjosh Jan 26 '19 at 10:44
  • **I'm getting this kind of error** Traceback (most recent call last): File "E:\Project 64\Working With Python\BMI Calculator.py", line 4, in height = float(input()) EOFError: EOF when reading a line – Debajit Jan 26 '19 at 10:50
  • Search for the error `EOFError: EOF when reading a line`. The code is right. – David Jan 27 '19 at 03:32

1 Answers1

0

raw_input only exists in Python 2.x. You should use input() in Python 3.

Lev Levitsky
  • 63,701
  • 20
  • 147
  • 175