DEV Community

Cover image for Dics Python
Natália Catunda
Natália Catunda

Posted on

4

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)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay