ဒီအခန်းပြီးရင်...
- dictionary ရဲ့ key-value pair သဘောတရားကို ရှင်းပြနိုင်မယ်
- dictionary ဖန်တီးနည်း (
{}နဲ့dict()) ကို သိမယ် []နဲ့.get()သုံးပြီး value တွေ ရယူနိုင်မယ် (KeyError ကို ရှောင်နိုင်မယ်)- entry အသစ်ထည့်တာ၊ ပြင်တာ၊ ဖျက်တာ (
del,pop(),popitem()) လုပ်တတ်မယ် keys(),values(),items()တွေနဲ့ dictionary ကို loop ပတ်နိုင်မယ်- nested dictionary တွေနဲ့ လက်တွေ့ mini project တွေ ရေးနိုင်မယ်
Dictionary ဆိုတာဘာလဲ
အရင်အခန်းတွေမှာ list, tuple, set တွေက item တွေကို တစ်ခုချင်း သိမ်းတယ်။ Dictionary ကတော့ မတူဘူး — သူက data တွေကို အတွဲ (pair) အဖြစ် သိမ်းတယ်။
အတွဲတစ်ခုမှာ အပိုင်း နှစ်ခု ပါတယ်။
- Key — ရှာဖွေဖို့ သုံးတဲ့ အမည် (စာအုပ်ရဲ့ အညွှန်းလိုမျိုး)
- Value — key နဲ့ တွဲထားတဲ့ တကယ့် data
လက်တွေ့ ဥပမာနဲ့ တွေးကြည့်ပါ — အဘိဓာန် (dictionary ဆိုတဲ့ အင်္ဂလိပ်စကားလုံးရဲ့ အဓိပ္ပာယ်ကိုက အဘိဓာန်ပါ)။ စကားလုံး (key) ကို ရှာပြီး အဓိပ္ပာယ် (value) ကို ရတယ်။ နောက် ဥပမာတစ်ခုက ဖုန်းစာအုပ် — လူနာမည် (key) ကို ရှာပြီး ဖုန်းနံပါတ် (value) ကို ရတယ်။
list က item တွေကို နံပါတ် (index) နဲ့ ရှာရပေမယ့်၊ dictionary ကတော့ key နဲ့ ရှာတယ်။ ဒါက dictionary ရဲ့ အကြီးမားဆုံး ကွာခြားချက်ပဲ။
dictionary ရဲ့ စည်းမျဉ်းတွေ:
- Key-value pairs — value တစ်ခုချင်းစီကို unique key တစ်ခုနဲ့ တွဲထားတယ်။
- Mutable — ဖန်တီးပြီးတဲ့နောက် ပြောင်းလဲနိုင်တယ်။
- Keys must be immutable and unique — key တွေက string, number, tuple လို မပြောင်းလဲနိုင်တဲ့ type တွေ ဖြစ်ရမယ်၊ ပြီးတော့ ထပ်လို့ မရဘူး။
- Insertion-ordered (Python 3.7+) — ထည့်တဲ့အစဉ်အတိုင်း သိမ်းထားတယ်။ (Python 3.7 မတိုင်ခင်တုန်းကတော့ unordered ဖြစ်ခဲ့တယ်။)
Dictionary ဖန်တီးခြင်း
dictionary ဖန်တီးဖို့ နည်းနှစ်ခု ရှိတယ်။
နည်းလမ်း 1: Curly braces {} နဲ့
key-value အတွဲတွေကို colon (:) နဲ့ ခွဲပြီး၊ အတွဲတွေကို comma နဲ့ ခြားရေးတယ်။
student = {"name": "Thura", "age": 21, "major": "Physics"}
print(student)
print(type(student))
{'name': 'Thura', 'age': 21, 'major': 'Physics'}
<class 'dict'>
နည်းလမ်း 2: dict() constructor နဲ့
teacher = dict(name="Daw Hla", subject="Math", years=12)
print(teacher)
{'name': 'Daw Hla', 'subject': 'Math', 'years': 12}
dict() နဲ့ ရေးတဲ့အခါ key တွေကို quote ထည့်စရာ မလိုဘူး — Python က အလိုအလျောက် string အဖြစ် သဘောထားတယ်။
အလွတ် dictionary
empty_dict = {}
also_empty = dict()
print(empty_dict)
{}
မှတ်ချက်: key တစ်ခုတည်း နှစ်ခါ ထည့်မိရင် နောက်ဆုံး value ကပဲ ကျန်တယ်။ အမှားမတက်ဘူး၊ တိတ်တိတ်လေး ဖုံးသွားတာ။
data = {"id": 101, "id": 202}
print(data)
{'id': 202}
Value များ ရယူနည်း — [] နဲ့ .get()
dictionary ထဲက value ကို ရယူဖို့ နည်းနှစ်ခု ရှိတယ်။ သူတို့နှစ်ခုရဲ့ ကွာခြားချက်ကို သေချာမှတ်ထားပါ — လက်တွေ့မှာ တော်တော် အရေးကြီးတယ်။
Square brackets [] နဲ့
student = {"name": "Thura", "age": 21, "major": "Physics"}
print(student["name"])
print(student["age"])
Thura
21
ဒါပေမယ့် မရှိတဲ့ key ကို [] နဲ့ တောင်းရင် KeyError တက်ပြီး program ရပ်သွားတယ်။
print(student["email"])
Traceback (most recent call last):
...
KeyError: 'email'
.get() method နဲ့
.get() က ပိုလုံခြုံတယ် — key မရှိရင် error မတက်ဘဲ None ပြန်ပေးတယ်။
print(student.get("major"))
print(student.get("email"))
Physics
None
default value ကိုယ်တိုင် သတ်မှတ်လို့လည်း ရတယ်။
print(student.get("email", "Not provided"))
print(student.get("phone", "No phone number"))
Not provided
No phone number
သတိပြုရန်: key ရှိမရှိ မသေချာတဲ့အခါ .get() သုံးပါ။ အထူးသဖြင့် အသုံးပြုသူ ရိုက်ထည့်တဲ့ key တွေ၊ file/database ကနေ ရလာတဲ့ data တွေနဲ့ အလုပ်လုပ်တဲ့အခါ [] က program ကို ရုတ်တရက် ရပ်ပစ်နိုင်တယ်။
Entry ထည့်သွင်း၊ ပြောင်းလဲ၊ ဖျက်ခြင်း
အသစ်ထည့်ခြင်း / ရှိပြီးသား ပြင်ခြင်း
key ကို [] နဲ့ assign လုပ်ရုံပဲ။ key အသစ်ဆို ထည့်သွားမယ်၊ ရှိပြီးသား key ဆို value ကို ပြင်သွားမယ်။
student = {"name": "Thura", "age": 21}
student["email"] = "thura@example.com"
print(student)
student["age"] = 22
print(student)
{'name': 'Thura', 'age': 21, 'email': 'thura@example.com'}
{'name': 'Thura', 'age': 22, 'email': 'thura@example.com'}
del — entry ဖျက်ခြင်း
profile = {"username": "thura22", "city": "Yangon", "hobby": "reading"}
del profile["hobby"]
print(profile)
{'username': 'thura22', 'city': 'Yangon'}
သတိပြုရန်: မရှိတဲ့ key ကို del လုပ်ရင် KeyError တက်တယ်။ [] နဲ့ value တောင်းသလိုပဲ၊ မသေချာရင် အရင် in နဲ့ စစ်ပါ။
pop() — ဖျက်ပြီး value ပြန်ယူခြင်း
pop() က key-value အတွဲကို ဖျက်တယ်၊ ပြီးတော့ value ကို ပြန်ပေးတယ်။
profile = {"username": "thura22", "city": "Yangon", "phone": "091234567"}
phone = profile.pop("phone")
print("Removed phone:", phone)
print(profile)
Removed phone: 091234567
{'username': 'thura22', 'city': 'Yangon'}
default ပေးထားရင် key မရှိလည်း error မတက်ဘူး။
result = profile.pop("address", "Not found")
print(result)
Not found
popitem() — နောက်ဆုံး entry ကို ဖျက်ခြင်း
Python 3.7+ မှာ popitem() က နောက်ဆုံးထည့်ထားတဲ့ key-value အတွဲကို ဖျက်ပြီး ပြန်ပေးတယ် (tuple အဖြစ်)။
profile = {"username": "thura22", "city": "Yangon", "hobby": "gaming"}
last_item = profile.popitem()
print("Last item removed:", last_item)
print(profile)
Last item removed: ('hobby', 'gaming')
{'username': 'thura22', 'city': 'Yangon'}
အကျဉ်းချုပ် table:
| နည်းလမ်း | အလုပ်လုပ်ပုံ |
|---|---|
d[key] = value |
အသစ်ထည့်တယ် / ရှိပြီးသား ပြင်တယ် |
del d[key] |
entry ဖျက်တယ် (မရှိရင် KeyError) |
d.pop(key) |
ဖျက်ပြီး value ပြန်ပေးတယ် |
d.pop(key, default) |
မရှိရင် default ပြန်ပေးတယ် (error မတက်) |
d.popitem() |
နောက်ဆုံး entry ကို ဖျက် + ပြန်ပေးတယ် |
အသုံးဝင်တဲ့ Dictionary method များ
keys(), values(), items()
dictionary ရဲ့ key တွေ၊ value တွေ၊ ဒါမှမဟုတ် အတွဲလိုက် ရယူဖို့ method သုံးခု ရှိတယ်။
person = {"name": "Mya", "age": 28, "city": "Mandalay"}
print(person.keys())
print(person.values())
print(person.items())
dict_keys(['name', 'age', 'city'])
dict_values(['Mya', 28, 'Mandalay'])
dict_items([('name', 'Mya'), ('age', 28), ('city', 'Mandalay')])
ထွက်လာတဲ့ dict_keys, dict_values, dict_items တွေကို list လို တိုက်ရိုက် index နဲ့ ယူလို့ မရဘူး။ list လိုချင်ရင် list() နဲ့ ပြောင်းပါ။
key_list = list(person.keys())
print(key_list)
print(key_list[0])
['name', 'age', 'city']
name
copy() — မိတ္တူ ကူးခြင်း
original = {"a": 1, "b": 2}
backup = original.copy()
backup["a"] = 100
print("Original:", original)
print("Copy:", backup)
Original: {'a': 1, 'b': 2}
Copy: {'a': 100, 'b': 2}
copy() မသုံးဘဲ backup = original လို့ တိုက်ရိုက် assign လုပ်ရင် dictionary နှစ်ခုလုံးက အတူတူ object ကို ညွှန်နေမယ် — တစ်ခုပြင်ရင် နှစ်ခုလုံး ပြောင်းသွားမယ်။ သီးခြား မိတ္တူ လိုချင်ရင် copy() သုံးရမယ်။
မှတ်ချက်: dictionary ထဲမှာ key တစ်ခု ရှိမရှိ စစ်ဖို့ in သုံးနိုင်တယ်။ in က key တွေကိုပဲ စစ်တယ်၊ value တွေကို မစစ်ဘူး။
person = {"name": "Mya", "age": 28}
print("name" in person)
print("Mya" in person)
True
False
Dictionary နဲ့ Loop ပတ်ခြင်း
dictionary ကို loop ပတ်ဖို့ နည်းသုံးမျိုး ရှိတယ် — ဘာလိုချင်သလဲပေါ် မူတည်ပြီး ရွေးသုံးတယ်။
Key တွေနဲ့ ပတ်ခြင်း
prices = {"apple": 500, "banana": 300, "orange": 700}
for item in prices:
print(item)
apple
banana
orange
dictionary ကို တိုက်ရိုက် loop ပတ်ရင် key တွေပဲ ရတယ်။ .keys() နဲ့ ရေးလည်း အတူတူပဲ။
Value တွေနဲ့ ပတ်ခြင်း
for price in prices.values():
print(price)
500
300
700
Key-value အတွဲလိုက် ပတ်ခြင်း
အသုံးအများဆုံးပုံစံပဲ — .items() နဲ့ variable နှစ်ခု တစ်ပြိုင်တည်း ယူတယ်။
for item, price in prices.items():
print(f"{item}: {price} kyats")
apple: 500 kyats
banana: 300 kyats
orange: 700 kyats
f-string နဲ့ တွဲသုံးရင် စျေးနှုန်းစာရင်းလို အစီရင်ခံစာတွေ လွယ်လွယ်ရေးနိုင်တယ်။
Nested Dictionary — Dictionary ထဲမှာ Dictionary
dictionary ရဲ့ value အဖြစ် နောက် dictionary တစ်ခု ထည့်နိုင်တယ်။ ဒါကို nested dictionary လို့ ခေါ်တယ်။ data တွေ အဆင့်ဆင့် ဖွဲ့စည်းထားတဲ့အခါ (ကျောင်း → ကျောင်းသား → ကျောင်းသားအချက်အလက်) အရမ်း အသုံးဝင်တယ်။
school = {
"name": "No. (1) Basic Education High School",
"students": {
"STU001": {"name": "Aung Khant", "grade": 10, "marks": 85},
"STU002": {"name": "Su Wai", "grade": 10, "marks": 92},
"STU003": {"name": "Min Thu", "grade": 9, "marks": 78}
}
}
အတွင်းထဲက value တစ်ခုကို ရယူဖို့ key တွေကို ဆက်တိုက် ရေးတယ်။
print(school["students"]["STU002"]["name"])
print(school["students"]["STU001"]["marks"])
Su Wai
85
ဖတ်ရတာ ဘယ်လိုလဲဆိုတာ ဖြည်းဖြည်းချင်း တွေးကြည့်ပါ — school ထဲက "students" key ကို ယူတယ်၊ ရလာတဲ့ dictionary ထဲက "STU002" ကို ယူတယ်၊ အဲဒီထဲက "name" ကို ယူတယ်။ အဆင့်ဆင့် ဆင်းသွားတာပါ။
entry အသစ် ထည့်တာလည်း အတူတူပဲ။
school["students"]["STU004"] = {"name": "Hnin Wai", "grade": 9, "marks": 88}
nested dictionary ကို loop ပတ်ကြည့်ရအောင်။
for student_id, info in school["students"].items():
print(f"{student_id}: {info['name']} (Grade {info['grade']}) - {info['marks']} marks")
STU001: Aung Khant (Grade 10) - 85 marks
STU002: Su Wai (Grade 10) - 92 marks
STU003: Min Thu (Grade 9) - 78 marks
STU004: Hnin Wai (Grade 9) - 88 marks
မှတ်ချက်: nested dictionary နဲ့ အလုပ်လုပ်တဲ့အခါ key တစ်ဆင့်ချင်းစီမှာ key ရှိ/မရှိ သတိထားပါ။ အလယ်အဆင့်က key မရှိရင် KeyError တက်တယ်။ လုံခြုံချင်ရင် .get() ကို အဆင့်တိုင်းမှာ သုံးနိုင်တယ်။
Mini Project 1: Contact Book
အခန်းရဲ့ အဓိက project — Contact Book (ဖုန်းစာအုပ်)။ လူနာမည် (key) နဲ့ ဖုန်းနံပါတ် (value) ကို dictionary ထဲမှာ သိမ်းမယ်။ dictionary သုံးဖို့ အသင့်တော်ဆုံး လက်တွေ့ ဥပမာပဲ — နာမည်နဲ့ ရှာရတာ သဘာဝကျတယ်။
လုပ်ဆောင်ချက်တွေ: contact ထည့်မယ်၊ ရှာမယ်၊ ပြင်မယ်၊ ဖျက်မယ်၊ အားလုံးပြမယ်။
contacts = {}
while True:
print("\n===== Contact Book =====")
print("1. Add Contact")
print("2. Search Contact")
print("3. Update Contact")
print("4. Delete Contact")
print("5. Display All Contacts")
print("6. Exit")
choice = input("Choose an option (1-6): ").strip()
if choice == "1":
name = input("Enter name: ").strip()
if not name:
print("Name cannot be empty.")
continue
if name in contacts:
print(f"'{name}' already exists. Use option 3 to update.")
continue
phone = input("Enter phone number: ").strip()
contacts[name] = phone
print(f"Contact '{name}' added.")
elif choice == "2":
name = input("Enter name to search: ").strip()
if name in contacts:
print(f"{name}'s phone number: {contacts[name]}")
else:
print("Contact not found.")
elif choice == "3":
name = input("Enter name to update: ").strip()
if name in contacts:
phone = input("Enter new phone number: ").strip()
contacts[name] = phone
print(f"Contact '{name}' updated.")
else:
print("Contact not found.")
elif choice == "4":
name = input("Enter name to delete: ").strip()
if name in contacts:
del contacts[name]
print(f"Contact '{name}' deleted.")
else:
print("Contact not found.")
elif choice == "5":
if not contacts:
print("Contact book is empty.")
else:
print(f"\nAll Contacts ({len(contacts)}):")
for name, phone in contacts.items():
print(f"- {name}: {phone}")
elif choice == "6":
print("Goodbye!")
break
else:
print("Invalid choice. Please enter a number from 1 to 6.")
ဒီ program မှာ ဒီအခန်းက သင်ခန်းစာတွေ အကုန်ပါဝင်တယ် — [] နဲ့ ထည့်တာ/ပြင်တာ၊ .get() နဲ့ လုံခြုံစွာ ရှာတာ၊ in နဲ့ key ရှိ/မရှိ စစ်တာ၊ del နဲ့ ဖျက်တာ၊ .items() နဲ့ loop ပတ်တာ။
နမူနာ အသုံးပြုပုံ:
===== Contact Book =====
1. Add Contact
2. Search Contact
3. Update Contact
4. Delete Contact
5. Display All Contacts
6. Exit
Choose an option (1-6): 1
Enter name: Aung Khant
Enter phone number: 091234567
Contact 'Aung Khant' added.
Mini Project 2: Inventory System
ဒုတိယ project — Inventory System (ပစ္စည်းစာရင်း)။ ဆိုင်တစ်ဆိုင်ရဲ့ ပစ္စည်း (key) နဲ့ လက်ကျန်အရေအတွက် (value) ကို မှတ်တမ်းတင်မယ်။
inventory = {}
while True:
print("\n===== Inventory System =====")
print("1. Add Item")
print("2. Update Quantity")
print("3. View Inventory")
print("4. Exit")
choice = input("Enter your choice: ").strip()
if choice == "1":
item = input("Enter item name: ").strip()
qty = int(input("Enter quantity: "))
inventory[item] = inventory.get(item, 0) + qty
print(f"Added {qty} x {item}. Total in stock: {inventory[item]}")
elif choice == "2":
item = input("Enter item name: ").strip()
if item in inventory:
qty = int(input("Enter new quantity: "))
inventory[item] = qty
print(f"Updated {item}'s quantity to {qty}.")
else:
print("Item not found.")
elif choice == "3":
if not inventory:
print("Inventory is empty.")
else:
print("\nCurrent Inventory:")
for item, qty in inventory.items():
print(f"- {item}: {qty}")
print(f"Total units in stock: {sum(inventory.values())}")
elif choice == "4":
print("Goodbye!")
break
else:
print("Invalid choice.")
inventory.get(item, 0) + qty ဆိုတဲ့ စာကြောင်းလေးကို သတိထားကြည့်ပါ — ပစ္စည်း အရင်က ရှိပြီးသားဆို လက်ကျန်အရေအတွက်ပေါ် ထပ်ပေါင်းတယ်၊ မရှိသေးရင် 0 ကနေ စတယ်။ .get() ရဲ့ default value က ဒီလိုနေရာမှာ တော်တော် အသုံးဝင်တယ်။
မှတ်ချက်: int(input(...)) က အသုံးပြုသူ စာရိုက်မှားရင် (ဥပမာ "abc") error တက်တယ်။ လက်တွေ့ program တွေမှာ try/except နဲ့ ကာကွယ်သင့်တယ် — Chapter 19 (Exception Handling) မှာ ဒါကို သင်မယ်။
Mini Project 3: Simple Banking System
တတိယ project — Simple Banking System။ အကောင့်ပိုင်ရှင် နာမည် (key) နဲ့ လက်ကျန်ငွေ (value) ကို dictionary ထဲမှာ သိမ်းမယ်။ အကောင့်ဖွင့်တာ၊ ငွေသွင်းတာ၊ ငွေထုတ်တာ၊ လက်ကျန်စစ်တာ လုပ်နိုင်တယ်။
accounts = {}
while True:
print("\n===== Simple Banking System =====")
print("1. Create Account")
print("2. Deposit")
print("3. Withdraw")
print("4. Check Balance")
print("5. Exit")
choice = input("Choose an option (1-5): ").strip()
if choice == "1":
name = input("Enter account holder name: ").strip()
if name in accounts:
print("Account already exists.")
else:
balance = float(input("Enter initial deposit: "))
if balance < 0:
print("Initial deposit cannot be negative.")
continue
accounts[name] = balance
print(f"Account created for {name} with balance {balance}.")
elif choice == "2":
name = input("Enter account holder name: ").strip()
if name in accounts:
amount = float(input("Enter amount to deposit: "))
if amount <= 0:
print("Deposit amount must be positive.")
continue
accounts[name] += amount
print(f"Deposited {amount}. New balance: {accounts[name]}")
else:
print("Account not found.")
elif choice == "3":
name = input("Enter account holder name: ").strip()
if name in accounts:
amount = float(input("Enter amount to withdraw: "))
if amount <= 0:
print("Withdrawal amount must be positive.")
elif amount > accounts[name]:
print("Insufficient balance.")
else:
accounts[name] -= amount
print(f"Withdrew {amount}. New balance: {accounts[name]}")
else:
print("Account not found.")
elif choice == "4":
name = input("Enter account holder name: ").strip()
if name in accounts:
print(f"{name}'s balance: {accounts[name]}")
else:
print("Account not found.")
elif choice == "5":
print("Thank you for using our banking system. Goodbye!")
break
else:
print("Invalid choice. Please select a number between 1 and 5.")
ဒီ system မှာ dictionary ရဲ့ key က လူတစ်ယောက်ချင်းစီကို ကိုယ်စားပြုတယ် — နာမည်နဲ့ အကောင့်ရှာတာ သဘာဝကျပြီး မြန်တယ်။ ငွေထုတ်တဲ့အခါ လက်ကျန်ထက် မကျော်အောင် စစ်ဆေးတာကလည်း လက်တွေ့ banking logic ရဲ့ အခြေခံပဲ။
စိတ်ဝင်စားရင် ဒီ project ကို ထပ်တိုးကြည့်ပါ — ဥပမာ အကောင့်ပိတ်တာ (delete), အကောင့်အားလုံးရဲ့ စုစုပေါင်း ငွေပမာဏ ပြတာ (sum(accounts.values())) တို့ပေါ့။
လေ့ကျင့်ခန်းများ
(လွယ်ကူသော) အောက်ပါ dictionary ကို ဖန်တီးပြီး၊ f-string တွေနဲ့ စာအုပ်အချက်အလက် တစ်ကြောင်းချင်း print ထုတ်ပါ။ ပြီးရင်
"year": 1997ဆိုတဲ့ entry အသစ်ထည့်ပြီး dictionary အပြည့်အစုံကို print ထုတ်ပါ။book = {"title": "Harry Potter", "author": "J.K. Rowling", "pages": 309}(အလယ်အလတ်) စာကြောင်းတစ်ကြောင်းထဲက စကားလုံးတစ်လုံးချင်း ဘယ်နှစ်ခါ ပါသလဲ ရေတွက်တဲ့ word frequency counter ရေးပါ။
.get()သုံးပြီး ရေတွက်ပါ။sentence = "the cat sat on the mat and the dog sat too" # မျှော်မှန်းရလဒ်: {'the': 3, 'cat': 1, 'sat': 2, 'on': 1, 'mat': 1, 'and': 1, 'dog': 1, 'too': 1}(အလယ်အလတ်) စျေးဝယ်ခြင်း program ရေးပါ။
prices = {"rice": 2500, "oil": 8500, "egg": 350, "sugar": 2200}ဆိုတဲ့ စျေးနှုန်း dictionary ရှိတယ်။ အသုံးပြုသူကို ပစ္စည်းနာမည်နဲ့ အရေအတွက် ရိုက်ခိုင်းပြီး စုစုပေါင်း ကျသင့်ငွေ တွက်ပါ။ စုစုပေါင်း 10000 ကျော်ရင် 10% လျှော့စျေး ပေးပါ။(ခက်သော) Gradebook program ရေးပါ။ ကျောင်းသားနာမည် (key) နဲ့ အမှတ်စာရင်း list (value) ကို nested ပုံစံမျိုး မဟုတ်ဘဲ dictionary ထဲမှာ သိမ်းပါ။
gradebook = {"Aung Khant": [85, 90, 78], "Su Wai": [92, 88, 95]}ကျောင်းသားတစ်ယောက်ချင်းစီရဲ့ ပျမ်းမျှအမှတ်ကို တွက်ပြီး၊ ပျမ်းမျှအမြင့်ဆုံး ကျောင်းသားကို ရှာပါ။ ကျောင်းသားအသစ် ထည့်နိုင်တဲ့ menu option လည်း ထည့်ပါ။
(စိန်ခေါ်မှု) English → Myanmar အဘိဓာန် dictionary တစ်ခု ပေးထားတယ်။
en_to_mm = {"apple": "ပန်းသီး", "book": "စာအုပ်", "water": "ရေ"}ဒါကို ပြောင်းပြန် လှန်ပြီး Myanmar → English dictionary (
{"ပန်းသီး": "apple", ...}) အဖြစ် ပြောင်းတဲ့ program ရေးပါ။ (အရိပ်အမြွက်:.items()နဲ့ loop ပတ်ပြီး key နဲ့ value နေရာချင်းလှန်ထည့်ပါ။)