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)