def convert(length, from_unit = 1, to_unit = 2):
"""
Converts lengths. The following lengths can be converted: meters, miles, nautical miles, yards, inches
:length: length to convert
:from_unit: 1=Meter, 2=Meilen, 3=Seemeilen, 4=Yard, 5=Inches
:to_unit: 1=Meter, 2=Meilen, 3=Seemeilen, 4=Yard, 5=Inches
:return: converted length
"""
if (from_unit == 1 or str(from_unit).casefold() == 'Meter'.casefold() ):
result = length
elif (from_unit == 2 or str(from_unit).casefold() == 'Meilen'.casefold() ):
result = length * 1609.34
elif (from_unit == 3 or str(from_unit).casefold() == 'Seemeilen'.casefold()):
result = length * 1852.0
elif (from_unit == 4 or str(from_unit).casefold() == 'Yard'.casefold()):
result = length * 0.9144
elif (from_unit == 5 or str(from_unit).casefold() == 'Inches'.casefold()):
result = length * 0.0254
if (to_unit == 1 or str(to_unit).casefold() == 'Meter'.casefold()):
return result
if (to_unit == 2 or str(to_unit).casefold() == 'Meilen'.casefold()):
result = result / 1609.34
return result
if (to_unit == 3 or str(to_unit).casefold() == 'Seemeilen'.casefold()):
result = result / 1852.0
return result
if (to_unit == 4 or str(to_unit).casefold() == 'Yard'.casefold()):
result = result / 0.9144
return result
if (to_unit == 5 or str(to_unit).casefold() == 'Inches'.casefold()):
result = result / 0.0254
return result
def main():
print('1=Meter, 2=Meilen, 3=Seemeilen, 4=Yard, 5=Inches')
print(convert(1000))
print(convert(1000,from_unit='Meilen', to_unit=5))
if __name__ == '__main__':
main()