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")
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")
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")
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()