-1

I'm trying to convert this meters to kilometers but I don't how to let the input to realize it's an integer

m = input("Enter the distance (meters) you want to convert to kilometers  ")
km =  1000
print (m/km,"km")
Jynx
  • 5
  • 4

2 Answers2

2

If you use Python 3 you can do this:

For taking int, you do this by m = int(input("Enter int"))

So, in your code just change input() to int(input()):

m = int(input("Enter the distance (meters) you want to convert to kilometers  "))
km =  1000
print (m/km,"km")
PM 2Ring
  • 54,345
  • 6
  • 82
  • 182
Sakib Ahammed
  • 2,452
  • 2
  • 25
  • 29
1
m = int(input("Enter the distance you want to convert (meters) "))
km =  1000
print (m/km,"km")

Note the conversion of m from str to int using int()

Vivek Anand
  • 621
  • 1
  • 7
  • 15
  • Thanks a lot (I did this a while ago seems like I forgot the other 2nd end parenthesis) – Jynx Sep 06 '15 at 12:36