Board logo

標題: 串列 (一) [打印本頁]

作者: 陳品肇    時間: 2020-2-2 09:00     標題: 串列 (一)

假設有一串列其內容如下:
list=["忠","孝","仁","愛","信","義","和","平"]

試取出串列中的第1到第5個元素
[attach]8361[/attach]
  1. list=["忠","孝","仁","愛","信","義","和","平"]
  2. print(list[1:6])
複製代碼

作者: 許雅棟    時間: 2020-2-2 10:33

  1. list=["忠","孝","仁","愛","信","義","和","平"]
  2. print(list[1:6])
複製代碼

作者: 黃紹綸    時間: 2020-2-2 10:33

  1. list=["忠","孝","仁","愛","信","義","和","平"]
  2. print(list[1:6])
複製代碼

作者: 陳頡鴻    時間: 2020-2-2 10:34

  1. list1=["忠","孝","仁","愛","信","義","和","平"]
  2. print(list1[1:6])
複製代碼

作者: 曾顗文    時間: 2020-2-2 10:34

  1. list=["忠","孝","仁","愛","信","義","和","平"]
  2. print(list[1:6])
複製代碼

作者: 曾柏忻    時間: 2020-2-2 10:35

  1. list=["忠","孝","仁","愛","信","義","和","平"]
  2. print(list[1:6])
複製代碼

作者: 李穎俊    時間: 2020-2-2 10:35

  1. list=["忠","孝","仁","愛","信","義","和","平"]
  2. print(list[1:6])
複製代碼

作者: 黃紹恩    時間: 2020-2-2 10:35

  1. list1=["忠","孝","仁","愛","信","義"]

  2. print(list1[1:6])
複製代碼

作者: 林依玟    時間: 2020-2-2 10:35

  1. list=["忠","孝","仁","愛","信","義"]
  2. print(list[1:6])
複製代碼

作者: 陳沛頤    時間: 2020-2-2 10:35

  1. list2=["0","1","2","3","4","5","6"]
  2. print(list2[1:6])
複製代碼

作者: 林奇陞    時間: 2020-2-2 10:36

  1. list=["忠","孝","仁","愛","信","義","和","平"]
  2. print(list[1:6])
複製代碼

作者: 傅英哲    時間: 2020-2-2 10:37

  1. list=["忠","孝","仁","愛","信","義","和","平"]
  2. print(list[1:6])
複製代碼

作者: 張鈞堯    時間: 2020-2-2 10:37

  1. a=[1,2,3,4,5]
  2. b=['a','b','c','d','e']
  3. c=[1,'a',2,'b',3]
  4. print(a[0:6])
  5. print(a[0:5])
  6. print(a[2:4])
  7. print(b[2:4])
  8. print(c[2:4])
  9. print(a,b,c)
  10. print(b[1])
  11. print(a[1])
  12. print(c[1])
複製代碼

作者: 黃柏叡    時間: 2020-2-2 10:37

  1. list1=[1,2,3,4,5,6,7,8,9]
  2. list2=["忠","孝","仁","愛","信","義","和","平"]
  3. list3=["看",1,2,"山"]
  4. print(list2[1:6])
複製代碼

作者: 傅品翰    時間: 2020-2-2 10:37

  1. list=["忠","孝","仁","愛","信","義","和","平"]
  2. print(list[1:6])
複製代碼

作者: 潘堉恩    時間: 2020-2-2 10:41

  1. list=["忠","孝","仁","愛","信","義","和","平"]
  2. print(list[1:6])
複製代碼





歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/) Powered by Discuz! 7.2