# This program converts US measurements
# to metric measurements.
# Constants for valid values
VALID_VALUE = 0
MAX_TEMP = 1000


def main():
        print('''
1.Miles to Kilometers.
2.Farenheit to Celsius.
3.Gallons to Liters.
4.Pounds to Kilograms.
5.Inches to centimeters.
6.Exit.
''')
        input('What would you like to convert?')
        if selection == '1':
            # Get the number of miles.
            miles_needed = int(input('Enter the number of miles: '))
            # Convert miles to kilometers.
            miles_to_kilometers(miles_needed)
        elif selection == '2':
            # Get the degrees farenheit.
            farenheit_needed = int(input('Enter the degrees Farenheit: '))
            # Convert fahrenheit to celsius.
            farenheit_to_celsius(farenheit_needed)
        elif selection == '3':
            # Get the number of gallons.
            gallons_needed = int(input('Enter the number of gallons: '))
            # Convert gallons to liters.
            gallons_to_liters(gallons_needed)
        elif selection == '4':
            # Get the number of pounds.
            pounds_needed = int(input('Enter the number of pounds: '))
            # Convert pounds to kilograms.
            pounds_to_kilograms(pounds_needed)
        elif selection == '5':
            # Get the number of inches.
            inches_needed = int(input('Enter the number of inches: '))
            # Convert inches to centimeters.
            inches_to_centimeters(inches_needed)
        elif selection == '6':
            break
        else:
            print ('Unknown option selected!')


# The intro function displays an introductory screen.
def intro():

    print('Hello Will, This program will convert')
    print('US measurements to Metric measurements,')
    print()


# The miles_to_kilometers function accepts a number
# of miles and displays the equivalent number of kilometers.
def miles_to_kilometers(miles):
    kilometers = miles * 1.6
    if miles > VALID_VALUE:
        print('That converts to', kilometers, 'kilometers.')
    else:
        print('Error invlaid value.')
    # Validate the VALID_VALUE.
    while miles < 0:
        print('Error: the value cannot be negative.')
        miles = int(input('Enter the number of miles: '))
        print('That converts to', kilometers, 'kilometers.')
        kilometers = miles * 1.6

# The farenheit_to_celsius function accepts a number
# of degrees and displays the equivalent number of celsius.
def farenheit_to_celsius(farenheit):
    celsius = (farenheit - 32) / 1.8
    if farenheit < MAX_TEMP:
        print('That converts to', celsius, 'celsius.')
    else:
        print('Error invalid value.')
    # Validate the VALID_VALUE.
    while farenheit > MAX_TEMP:
        print('Error: the value cannot be >1000 degrees.')
        farenheit = int(input('Enter the degrees farenheit: '))
        print('That converts to', celsius, 'celsius.')

# The gallons_to_liters function accepts a number
# of gallons and displays the equivalent number of liters.
def gallons_to_liters(gallons):
    liters = gallons / .26417
    print('That converts to', liters, 'liters.')

# The pounds_to_kilograms function accepts a number
# of pounds and displays the equivalent number of kilograms.
def pounds_to_kilograms(pounds):
    kilograms = pounds / 2.2
    if pounds > VALID_VALUE:
        print('That converts to', kilograms, 'kilograms.')
    else:
        print('Error invalid value.')


# The inches_to_centimeters function accepts a number
# of inches and displays the equivalent number of centimeters.
def inches_to_centimeters(inches):
    centimeters = inches / .3937
    if inches > VALID_VALUE:
        print('That converts to', centimeters, 'centimeters.')
    else:
        print('Error invalid value.')


# Call the main function.
main()

this is what i have so far but the program won't run due to an indention error or an error related to the break.

In Python you cannot mix spaces and tabs in indenting your code. That means if you used spaces to indent your code, then you have to be consistent in using spaces all the time and not alternate it with tabs. Also you have to be consistent with the number of spaces you use. You missed a few things in your program also. In line 14, you should've assigned the result of input() to your selection variable: selection = input('What would you like to convert?'). You should also remove the single quotes from the integers in your if-elif-else statements: elif selection == 2:; and on line 43, replace your break statement with pass.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.