Hello guys, here I have a question about the extra task in the string medical insurance project:
Here I have 4 lists:
Names: [‘MARINA ALLISON’, ‘MARKUS VALDEZ’, ‘CONNIE BALLARD’, ‘DARNELL WEBER’, ‘SYLVIE CHARLES’, ‘VINAY PADILLA’, ‘MEREDITH SANTIAGO’, ‘ANDRE MCCARTY’, ‘LORENA HODSON’, ‘ISAAC VU’]
Ages: [‘27’, ‘30’, ‘43’, ‘35’, ‘22’, ‘24’, ‘51’, ‘19’, ‘65’, ‘34’]
BMI: [‘31.1’, ‘22.4’, ‘25.3’, ‘20.6’, ‘22.1’, ‘26.9’, ‘29.3’, ‘22.7’, ‘33.1’, ‘24.8’]
Insurance Costs: [’$7010.0’, ‘$4050.0’, ‘$12060.0’, ‘$7500.0’, ‘$3022.0’, ‘$4620.0’, ‘$16330.0’, ‘$2900.0’, ‘$19370.0’, ‘$7045.0’]
And the task is to write a for loop that outputs a string for each individual in the following format:
Marina is 27 year olds with a BMI of 31.1 and an insurance cost of $7010.0.
Markus is 30 years old with a BMI of 22.4 and an insurance cost of $4050.0
…
…
I have tried different ways such as:
for name in names:
for age in ages:
for bmi in bmis:
for insurance_cost in insurance_costs:
print(name + " is " + str(age) + " year olds with a BMI of " + str(bmi) + " and an insurance cost of " + insurance_cost + “.”)
and
for name, age, bmi, insurance_cost in names, ages, bmis, insurance_costs:
return "{} is {} year olds with a BMI of {} and an insurance cost of {}. ".format(name, age, bmi, insurance_cost)
Both of my ways are wrong. So I wonder what code I should put for this for loop.
Thanks a lot and happy coding!