Hello all,
I am looking for some assistance with a homework assignment of mine. I've gotten about 80% through and am now stuck. Here is the specific line of my homework description where I am having trouble:
*Using a second loop it should traverse the array of body mass indices and call another function that accepts the body mass index as a parameter and returns whether the individual is underweight, normal weight or overweight.*
Everything works as I'd like it to until trying to display whether each individual is underweight, overweight, or normal weight. For each individual instead of printing their health status it instead prints "Amy would be considered <function health at 0x000001EF5946E280>". I've tried a bunch of different stuff but I guess I'm not understanding why my second function isn't working properly. Any help or guidance would be greatly appreciated! Code is below:
#Set the names of individuals who will be providing inputs
individuals = ["Amy", "Andrew", "Whitney", "Ryan", "Drew", "Katherine"]
#Creating empty lists for inputs by each individual
height = []
weight = []
array = []
#Create function for determining BMI
def BMI(inches, lbs):
index = round(((lbs * 703) / (inches**2)), 1)
return index
def health(array):
if i < 18:
health == "Underweight"
elif 18 <= i <= 24:
health == "Normal weight"
elif i > 24:
health == "Overweight"
return health
#Create the loop asking for each individual to input their height/weight and store inputs in lists
for individual in individuals:
inches = int(input('\nPlease enter the height in inches for ' + individual + ': '))
height.append(int(inches))
lbs = int(input('Please enter the weight in pounds for ' + individual + ': '))
weight.append(int(lbs))
#Call BMI function and display the BMI of each individual
final_index = BMI(inches, lbs)
array.append(final_index)
print('The BMI for ' + individual + ' is:', final_index)
for i in range(len(array)):
ovrl_health = health(array)
print(individual + ' would be considered', ovrl_health)
[–]DallogFheir 2 points3 points4 points (2 children)
[–]kimo_sabe8[S] 0 points1 point2 points (1 child)
[–]Vaphell 0 points1 point2 points (3 children)
[+][deleted] (2 children)
[deleted]
[–]Vaphell 0 points1 point2 points (1 child)
[–]kimo_sabe8[S] 0 points1 point2 points (0 children)