VOOZH about

URL: https://www.digitalocean.com/community/tutorials/python-data-types

โ‡ฑ Understanding Python Data Types | DigitalOcean


๐Ÿ‘ Understanding Python Data Types

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about our products

About the author(s)

๐Ÿ‘ Anish Singh Walia
Anish Singh Walia
Author
Sr Technical Content Strategist and Team Lead
See author profile

I help Businesses scale with AI x SEO x (authentic) Content that revives traffic and keeps leads flowing | 3,000,000+ Average monthly readers on Medium | Sr Technical Writer(Team Lead) @ DigitalOcean | Ex-Cloud Consultant @ AMEX | Ex-Site Reliability Engineer(DevOps)@Nutanix

Java and Python Developer for 20+ years, Open Source Enthusiast, Founder of https://www.askpython.com/, https://www.linuxfordevices.com/, and JournalDev.com (acquired by DigitalOcean). Passionate about writing technical articles and sharing knowledge with others. Love Java, Python, Unix and related technologies. Follow my X @PankajWebDev

๐Ÿ‘ Vinayak Baranwal
Vinayak Baranwal
Editor
Technical Writer II
See author profile

Building future-ready infrastructure with Linux, Cloud, and DevOps. Full Stack Developer & System Administrator. Technical Writer @ DigitalOcean | GitHub Contributor | Passionate about Docker, PostgreSQL, and Open Source | Exploring NLP & AI-TensorFlow | Nailed over 50+ deployments across production environments.

Category:
Tags:

Still looking for an answer?

Was this helpful?

the code for dictionary data type is wrong โ€ฆas the key is always surrounded by double quotes โ€œkeyโ€ correct code:- a = {โ€œ1โ€:โ€œfirst nameโ€,โ€œ2โ€:โ€œlast nameโ€, โ€œageโ€:33} #print value having key=1 print(a[โ€œ1โ€]) #print value having key=2 print(a[โ€œ2โ€]) #print value having key=โ€œageโ€ print(a[โ€œageโ€])

- Shubham

@Shubham, This is not necessary. Double are required compulsory for text/strings whether you use them as Key or Value. Whenever you are using numeric as key or value, it is not mandatory that you have to use double quotes but if you are using string then you have to use it. For ex.: Case 1 : Numeric as Key without quotes and String as value a={1:โ€œOneโ€,2:โ€œTwoโ€,โ€œAgeโ€:35} >>> a[1] โ€˜Oneโ€™ Case 2: Numeric as Key in quotes and String as value >>> a={โ€œ1โ€:โ€œOneโ€,2:โ€œTwoโ€,โ€œAgeโ€:35} >>> a[โ€œ1โ€] โ€˜Oneโ€™ Case 3: String as Key and Numeric as value >>> a={โ€œOneโ€:1,2:โ€œTwoโ€,โ€œAgeโ€:35} >>> a[โ€œOneโ€] 1 Hope it is clear. Thanks

- Nidhesh Tiwari

๐Ÿ‘ Creative Commons
This work is licensed under a Creative Commons Attribution-NonCommercial- ShareAlike 4.0 International License.
  • Deploy on DigitalOcean

    Click below to sign up for DigitalOcean's virtual machines, Databases, and AIML products.

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and AI-native businesses

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOceanโ€™s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow โ€” whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

ยฉ 2026 DigitalOcean, LLC.Sitemap.
Dark mode is coming soon.