0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 7
click for more info
No active XP Potion
Accept a Quest
Login to submit answers
If you're unsure whether a key exists in a dictionary, use the in
keyword.
cars = {
"ford": "f150",
"toyota": "camry"
}
print("ford" in cars)
# Prints: True
print("gmc" in cars)
# Prints: False
We need to be able to report to our players how many enemies are in their immediate vicinity - but they want the count of each enemy by its kind. Fix the count_enemies
function. It accepts as input:
enemy_names
: a list of strings.It should return a dictionary where:
Check whether a key is in the dictionary before trying to update its value. If it isn't, set it.
Focus Editor
Alt+Shift+]
Next Tab
Alt+Shift+[
Become a member to Submit
Become a member to Run
Become a member to view solution