mercredi 15 juin 2016

syntax error when trying to use return and print functions (one specific instance) in python 3


Can you help me get the second print function to work? I keep getting a syntax error for it

print('Program to convert grams of micronutrients to kcal')
protein=input('Enter grams of protein:')
carbohydrates=input('Enter grams of carbohydrates:')
fat=input('Enter grams of fat:')

def protein_kcal(protein):
        kcal=protein*4
        return kcal

def carbohydrate_kcal(carbohydrates):
        kcal=carbohydrates*4
        return kcal

def fat_kcal(fat):
        kcal=fat*9
        return kcal

def total_calories(protein, carbohydrates, fat):
        return(protein_kcal(protein) + carbohydrate_kcal(carbohydrates) + fat_kcal(fat)

print('total kcal=', total_calories(protein, carbohydrates, fat))  # this is the line I get an error on

Aucun commentaire:

Enregistrer un commentaire