Quick actions

cmd+k|ctrl+k

Navigation

Languages

Zero to Mastery course Python

Snippet info

Language

Python

Visibility

public

Author

arrexshoot

Created

2025-08-13T13:17:17.073407Z

Updated

2025-08-13T13:38:13.788982Z

# Exercise Dictionary Methods
# Scroll to see answers.

# 1 Create a user profile for your new game.
# This user profile will be stored in a dictionary with keys: 'age', 'username', 'weapons', 'is_active' and 'clan'

# 2 iterate and print all the keys in the above user.

# 3 Add a new weapon to your user

# 4 Add a new key to include 'is_banned'. Set it to false

# 5 Ban the user by setting the previous key to True

# 6 create a new user2 my copying the previous user and update the age value and username value.

#ANSWER BELOW



























user_profile = {
    'username' : 'Elpiberats',
    'age' : 41,
    'weapons' : None,
    'is_active' : True,
    'clan' : None
}

# print(user_profile.items())
user_profile.update({'weapons' : 'Katana'}) #OR user_profile['weapons'] = 'Katana'
user_profile.update({'is_banned' : False})
user_profile.update({'is_banned' : True}) #OR user_profile['is_banned'] = True

user_profile2 = user_profile
user_profile2.update({'username' : 'Chiquitik', 'age' : 40})
print(user_profile2)

INFO