0

why do I get an error? I just want to print the country_counts variable

https://code.sololearn.com/c6UWk3Lc9mJG/?ref=app

23rd Jan 2018, 4:41 PM
‫אוהד פניכל‬‎
‫אוהד פניכל‬‎ - avatar
4 Réponses
+ 6
You have to put the country names between quotes: country_list = ["australia", "australia", "uganda"] Also, dictionaries do not have .add() method. Use .update() instead. Finally, you have to consider the case when there already is a country entry in the dictionary, before you print the country_counts. To sum up, it should go like this: country_list = ["australia", "australia" , "uganda"] country_counts = {} for country in country_list: if country not in country_counts : country_counts.update({country: 1}) else: country_counts[country] += 1 print(country_counts)
23rd Jan 2018, 5:41 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 1
you are missing an indented block... just like the error message tells you
23rd Jan 2018, 5:35 PM
Jeremy
Jeremy - avatar
0
how would you fix it? I don't understand where I should indent it. sorry for the noob question
23rd Jan 2018, 5:41 PM
‫אוהד פניכל‬‎
‫אוהד פניכל‬‎ - avatar
0
thanks a lot guys I got it!
23rd Jan 2018, 5:53 PM
‫אוהד פניכל‬‎
‫אוהד פניכל‬‎ - avatar