I have this following problem from a book I’m learning from and I'd like to know how you would interpret this code to get to the answer (14) because I’m having a hard time getting there. I understand the concept of for loops but this nested one got me good:
When the looping completes, what number will display?
outer_loop_total = 0
inner_loop_total = 0
countries = ["Albania", "Morocco", "Brazil", "Denmark"]
capitals = ["Tel Aviv", "Abuja", "Brasília", "Islamabad"]
for country_to_check in countries:
outer_loop_total += 1
for city_to_check in capitals:
inner_loop_total += 1
if country_to_check == "Brazil" and city_to_check == "Brasília":
print(outer_loop_total + inner_loop_total)