Exercise Problem on Dictionaries Week 5

Hi ,

My solution for the dictionary problem week 5 is following :-

Note :- ( I have predefined the string, only used two dictionary key values and lat-long values are random numbers for sake of simplicity.)


The error which comes is following :-

What did I do wrong ?

l1.split() This function makes a list of string and when used in for loop ; it cannot iterate as the indices i.e “x” in this case must be an integer and not a string.

To rectify this error, try
for x in range(len(l1))
This will convert the looping variable (“x” in this case ) from string to an integer.

1 Like