Unable to complete Exercise 4 module 2

I’m on the 4th exercise and I’m just not understanding how to compare the values from the different lists. I get errors that “string indeces must be integers not str” and i’ve looked over the past labs and I just can’t see where we were taught how to do this. I got all the other exercises of the project done successfully but if I try to submit it without this one I automatically fail.

it also won’t let me create variables or anything to try and make it work. It seems to just want a very specific line of code that i can’t figure out. Its due in 2 hours but I just don’t get it and the previous sections just show how to compare bool or int’s.

if I fail this project could I still pass? Do the other projects need you to learn concepts outside the course?

Sorry, I’m not a mentor for this course. But here is some general guidance.

Don’t worry about the deadlines. They are only reminders.

No, you must pass all assignments to complete the course.

None of the courses require you to learn outside the course. But some (or most?) courses assume you already are at least at the entry level of Python coding skill.

Hi @josimba ,

If you look back to the section about datatype, you would see that numbers are represented as integers, such as 1,2,3 or 100, and strings are enclosed in quotation such as ‘ ‘ or “ “.
let’s say if you have a variable named index, and you assign it a value of 2, then you can get the 3rd element of the list:
MytoDoList=[“shopping”, “cleaning”, “visit grandpa”]
let index =2
then
MytoDoList[index] would fetch the 3rd element on the list, which is “visit grandpa”.
however if you set index to be a string value:
let index =“2”
this would result in an error as index has to be an integer.

I don’t have access to this exercise, so I don’t know the exact instruction of what you need to do. But I hope by understanding the difference between integer and str datatype, you would be able to resolve this issue.

the issue with creating new variables is this exercise has a built in variable and it gives me an error as the exercise does not want additional variables created so I wasn’t able to do this type of solution

so even though the project has a weight of 10% if I fail to complete it I will fail the whole course?

It is most likely that your strategy for this assignment is not correct.

It might be beneficial if you abandon your present effort and start over with a fresh approach.

No one else is reporting this issue, so it’s very likely not an issue with the assignment.

Hi @josimba,

If you pay attention to the exercise instructions and the code comments, you’ll realise, the answer is somewhat provided in them.


First instruction: * Use a for loop to iterate through borrowers_list.
First code comment: # Look for ‘borrower’ in borrowers_list

Second instruction: Check if the name in book['borrower'] matches with a “name” present in the borrowers_list
Second code comment: # Check if the name “book[‘borrower’]” equals “borrower[‘name’]”

Third instruction: If the name matches, store the corresponding “email” in a variable borrower_email
Third code comment: Set “borrower_email” equals “borrower[‘email’]”


These are all concepts that have been taught to you in the lectures, but not necessarily in a single lecture.

Hope this helps,
Mubsi