DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Cover image for Dics Python
NatΓ‘lia Catunda
NatΓ‘lia Catunda

Posted on

Dics Python

Today I'll talking about dictionaries ,
nicknamed affectionately dics!
with keys and values...

user={
        "name":"NatΓ‘lia",
        "age":27,
        "city":"fortaleza"
}
GetAge=user.get("age")
print(user)
user.pop("age")
print(user)
user["age"]=28
print(user)
Enter fullscreen mode Exit fullscreen mode

Our keys:"name","age" and "city"
with values:"NatΓ‘lia",27 and "fortaleza"
with .get() method we get the key of our dic that take us for get the especific value,and .pop() where we put a new "key":"value" on our code.

GetAge=user.get("age")
user.pop("age")
Enter fullscreen mode Exit fullscreen mode

and with a new value we can make something like:

user["age"]=28
Enter fullscreen mode Exit fullscreen mode

Thanks for reading!

Top comments (0)

Create an Account!

πŸ‘€ Just want to lurk?

That's fine, you can still create an account and turn on features like 🌚 dark mode.