Ainsteinx Logo
Ainsteinx
👤
Welcome to Ainsteinx
Login

Change Language

Currency

Home
Blog
Services
All lessons
EP.6 Python for Laos

Dictionaries: look things up by name

words = {"ໝາ": "dog", "ແມວ": "cat", "ນົກ": "bird"}

print(words["ແມວ"])
words["ປາ"] = "fish"
print(len(words))
Video coming soon
EP.6 Data & structures

Dictionaries: look things up by name

Look up Lao → English translations with a dict.

A dict stores key: value pairs inside curly braces { }. You look values up by key instead of by position.

It suits named data, such as product prices or your friends' phone numbers.

ep06-dictionaries.py
words = {"ໝາ": "dog", "ແມວ": "cat", "ນົກ": "bird"}

print(words["ແມວ"])
words["ປາ"] = "fish"
print(len(words))

Output

cat
4
  • #PythonສຳລັບຄົນLaos
  • #Python
  • #ຮຽນໂປຣແກຣມ
  • #ບອກຕໍ່ຄວາມຮູ້
  • #shorts

Watch and share on