Board logo

標題: for 迴圈 (二) [打印本頁]

作者: 陳品肇    時間: 2020-2-2 11:22     標題: for 迴圈 (二)

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

試以for迴圈,橫向顯示串列中的所有元素。
[attach]8364[/attach]
  1. list=["忠","孝","仁","愛","信","義","和","平"]
  2. for s in list:
  3.     print(s,end=" ")
複製代碼
  1. list=["忠","孝","仁","愛","信","義","和","平"]
  2. for i in range(0,8):
  3.     print(list[i],end=" ")
複製代碼

作者: 陳頡鴻    時間: 2020-2-2 13:32

  1. listai1=["忠","孝","仁","愛","信","義","和","平"]
  2. for s in listai1:
  3.     print(s,end=" ")
複製代碼
  1. listai2=["忠","孝","仁","愛","信","義","和","平"]
  2. for i in range(0,8):
  3.     print(listai2[i],end=" ")
複製代碼

作者: 李穎俊    時間: 2020-2-2 13:33

  1. list=["忠","孝","仁","愛","信","義","和","平"]
  2. for s in list:
  3.     print(s,end=" ")
複製代碼
  1. list=["忠","孝","仁","愛","信","義","和","平"]
  2. for i in range(0,8):
  3.     print(list[i],end=" ")
複製代碼

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

  1. list=["忠","孝","仁","愛","信","義","和","平"]
  2. for s in list:
  3.     print(s,end=" "
複製代碼
  1. list=["忠","孝","仁","愛","信","義","和","平"]
  2. for i in range(0,8):
  3.     print(list[i],end=" ")
複製代碼

作者: 黃紹恩    時間: 2020-2-2 13:34

  1. list=["忠","孝","仁","愛","信","義","和","平"]

  2. for i in range(0,8):
  3.     print(list[i],end="")
複製代碼

作者: 曾柏忻    時間: 2020-2-2 13:34

  1. list=["忠","孝","仁","愛","信","義","和","平"]
  2. for I in list:
  3.     print(I,end="")
  4. print()
  5. list=["忠","孝","仁","愛","信","義","和","平"]
  6. for i in range(0,8):
  7.     print(list[i],end="")
複製代碼

作者: 陳沛頤    時間: 2020-2-2 13:34

  1. list1=["忠","孝","仁","愛","信","義","和","平"]
  2. for i in list:
  3.     print(i,end=" ")
  4. print()
  5. list=["忠","孝","仁","愛","信","義","和","平"]
  6. for i in range(0,8):
  7.     print(list[i],end=" ")
複製代碼

作者: 潘堉恩    時間: 2020-2-2 13:35

  1. list=["忠","孝","仁","愛","信","義","和","平"]
  2. for s in list:
  3.     print(s,end=" ")   
  4.    
  5. print()

  6. list=["忠","孝","仁","愛","信","義","和","平"]
  7. for i in range(0,8):
  8.     print(list[i],end=" ")   
複製代碼

作者: 許雅棟    時間: 2020-2-2 13:37

  1. list=["忠","孝","仁","愛","信","義","和","平"]
  2. for y in list:
  3.     print(y,end="!")


  4. print()


  5. list=["忠","孝","仁","愛","信","義","和","平"]
  6. for x in range(0,8):
  7.     print(list[x],end="~")
複製代碼

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

  1. list=["忠","孝","仁","愛","信","義","和","平"]
  2. for s in list:
  3.     print(s,end=" ")


  4. list=["忠","孝","仁","愛","信","義","和","平"]
  5. for i in range(0,8):
  6.     print(list[i],end=" ")
  7.    
  8.    
  9.    
複製代碼

作者: 曾顗文    時間: 2020-2-2 13:38

  1. [code][code]list=["忠","孝","仁","愛","信","義","和","平"]
  2. for s in list:
  3.     print(s,end=" ")
複製代碼
[/code][/code]
  1. list=["忠","孝","仁","愛","信","義","和","平"]
  2. for i in range(0,8):
  3.     print(list[i],end=" ")
複製代碼

作者: 林奇陞    時間: 2020-2-2 13:38

  1. list=["忠","孝","仁","愛","信","義","和","平"]
  2. for i in range(0,8):
  3.     print(list[i],end=" ")
複製代碼

作者: 黃柏叡    時間: 2020-2-2 13:40

  1. list=["忠","孝","仁","愛","信","義","和","平"]
  2. for i in list:
  3.     print(i,end=" ")
  4.    
  5. print()

  6. for a in range(0,7):
  7.     print(list[a],end=" ")
  8.    

  9.    
複製代碼

作者: 林依玟    時間: 2020-2-2 13:40

  1. list=["忠","孝","仁","愛","信","義","和","平"]
  2. for s in list:
  3.     print(s,end=" "
複製代碼

作者: 傅英哲    時間: 2020-2-2 13:40

  1. list=["忠","孝","仁","愛","信","義","和","平"]
  2. for s in list:
  3.     print(s,end="")

  4. print()
  5. list=["忠","孝","仁","愛","信","義","和","平"]
  6. for i in range(0,8):
  7.     print(list[i],end="")
複製代碼

作者: 林依玟    時間: 2020-2-2 13:41

  1. list=["忠","孝","仁","愛","信","義","和","平"]
  2. for i in range(0,8):
  3.     print(list[i],end=" ")
複製代碼

作者: 黃柏叡    時間: 2020-2-2 14:34

  1. list3=range(1,100,2)

  2. for i in list3:
  3.     print(i,end=" ")
複製代碼





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