Board logo

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

作者: tonyh    時間: 2020-7-28 09:51     標題: 串列 (一)

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

試取出串列中的第1到第5個元素

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

作者: 陳紀希    時間: 2020-7-28 10:23

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

作者: 王法棣    時間: 2020-7-28 10:25

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

作者: 楊書華    時間: 2020-7-28 10:25

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

作者: 楊子瑩    時間: 2020-7-28 10:26

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

作者: 李睿騏    時間: 2020-7-28 10:27

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

作者: 黃明晧    時間: 2020-7-28 10:28

list1=["Moo","Woof","Meow","Chirp","Fumperdink"]
print (list1 [4:5])
#Why are we still here, just to suffer.
作者: 林睿謙    時間: 2020-7-28 10:29

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

作者: 林婕瀅    時間: 2020-7-28 10:30

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

作者: 黃家穎    時間: 2020-7-28 10:30

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

作者: 林家代    時間: 2020-7-28 10:31

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

作者: 陳星翰    時間: 2020-7-28 10:31

  1. list=["Raymond","is","stupid","dumb","very stupid","noob","trash"]
  2. print(list[0:6])
複製代碼

作者: 戴睿呈    時間: 2020-7-28 10:31

  1. list=["Hudson","IS","dumb","stupid","noob","and trash"]
  2. print(list[0:6])
複製代碼

作者: 黃瀚永    時間: 2020-7-28 10:32

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

作者: 黃明曄    時間: 2020-7-28 10:32

  1. list=["booo","yaaay","hello","blaahhhh"]
  2. print(list[0:1])
複製代碼





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