Welcome to the Get Help category!
I am attempting the extra work (task #22) in the Python Strings Medical Insurance Project. The task is this:
- 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......
We already have separated out all of the relevant information into separate lists of: names, ages, bmis, insurance_costs.
My attempted code looks like this:
for i in names:
i = 0
print(names[i] + ’ is ’ + ages[i] + ’ years old with a BMI of ’ + bmis[i] + ’ and an insurance cost of ’ + insurance_costs[i] + ‘.’)
i += 1
The output prints the same information ten times, all of it the information for indices. Why is it not moving to the next indices when it prints? Any help would be great!
This is where you can ask questions about your code. Some important things to remember when posting in this category
- Learn how to ask a good question and get a good answer!
- Remember to include a link to the exercise you need help with!
- If someone answers your question, please mark their response as a solution
- Once you understand a new concept, come back and try to help someone else!