Ainsteinx Logo
Ainsteinx
👤
Welcome to Ainsteinx
Login

Change Language

Currency

Home
Blog
Services
ທຸກບົດຮຽນ
EP.5 Python ສຳລັບຄົນ Laos

Lists: many things in one place

cities = ["ວຽງຈັນ", "ຫຼວງພະບາງ", "ປາກເຊ"]
cities.append("ສະຫວັນນະເຂດ")

print(cities[0])
print(len(cities))
Video coming soon
EP.5 ຂໍ້ມູນ ແລະ ໂຄງສ້າງ

Lists: many things in one place

Can one variable hold many items? Yes, with a list.

list ຂຽນດ້ວຍວົງເລັບ [ ]. ສະມາຊິກທຳອິດຢູ່ຕຳແໜ່ງ 0, ບໍ່ແມ່ນ 1.

ໃຊ້ .append() ເພີ່ມສະມາຊິກໃໝ່ ແລະ len() ນັບວ່າມີຈັກອັນ.

ep05-lists.py
cities = ["ວຽງຈັນ", "ຫຼວງພະບາງ", "ປາກເຊ"]
cities.append("ສະຫວັນນະເຂດ")

print(cities[0])
print(len(cities))

ຜົນລັບ

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