Hello, this is my first post in this forum. I recently decided to try my hand at programming with python. I'm completely new to programming so I thought I should try some simple projects to reinforce what I've learned so far.
I saw a post from 3 years ago on this forum about a unit converter that has to work with inches, feet, miles, millimeters, centimeters, meters, and kilometers, and thought it would be a good project to try. So far I've only written enough script to convert from inches to any of the units mentioned above. I've got the feeling I'm going about this in the wrong way, so I wanted to see what you guys think about the code I've written so far before i go any further.
Please let me know if the way I'm writing this is wrong, or if there might be a better/more efficient way of writing this program.
def main():
start = raw_input ("Convert from? ")
if start == "inches":
return inches()
elif start == "feet":
return feet()
elif start == "miles":
return miles()
elif start == "millimeters":
return millimeters()
elif start == "centimeters":
return centimeters()
elif start == "meters":
return meters()
elif start == "kilometers":
return kilometers()
else:
return main()
def inches():
end = raw_input("Convert to? ")
value = input("Value? ")
feet1 = value / 12.0
miles1 = value / 63360.0
millimeters1 = value * 25.4
centimeters1 = value * 2.54
meters1 = value * 0.0254
kilometers1 = value * .0000254
if end == "feet":
print "\n\n", feet1, "feet\n\n"
return main()
elif end == "miles":
print "\n\n", miles1, "miles\n\n"
return main()
elif end == "millimeters":
print "\n\n", millimeters1, "millimeters\n\n"
return main()
elif end == "centimeters":
print "\n\n", centimeters1, "centimeters\n\n"
return main()
elif end == "meters":
print "\n\n", meters1, "meters\n\n"
return main()
elif end == "kilometers":
print "\n\n", kilometers1, "kilometers\n\n"
return main()
main()