My question is whether something similar to this would make sense (way 2 in the screenshot below) or if it wouldn’t be possible? I am trying if an else statements inside a for loop to add dictionary values to keys that are not ‘17+’. Or is way 1 more straight - forward/ easier?
In #way 2, you are checking if '17+' in content ratings: on each iteration, which will always evaluate to True as 17+ exists in content_ratings dictionary. Therefore, the else: block will not be executed and app_15_allowed dictionary will stay empty.
Hi @thaisalemr,
in #way 2 you can change the condition to if value == ‘17+’
apps_15_allowed = 0
for value in content_rationgs:
if value == '17+':
apps_17_plus = content_rationgs[value]
else:
apps_15_allowed += content_rationgs[value]