Board logo

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

作者: 鄭繼威    時間: 2023-7-10 15:59     標題: for 迴圈 (二)

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

試以for迴圈,橫向顯示串列中的所有元素。

  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=" ")
複製代碼

作者: 方昱安    時間: 2023-7-11 10:33

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

作者: 劉恆    時間: 2023-7-11 10:52

list=["忠","孝","仁","愛","信","義","和","平"]
for s in list:
    print(s,end=" ")
作者: 董炫霆    時間: 2023-7-11 10:55

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

作者: 歐陽霖    時間: 2023-7-11 10:58

  1. list3=["和","平","誠","信","敬","業","樂","群" ]
  2. for i in list3:
  3.     print(i,end=" ")
複製代碼

作者: 曾冠瑋    時間: 2023-7-11 11:01

list1=["忠","孝","仁","愛","信","義","和","平"]
for i in list1:
     print(i,end=" ")
作者: 黃柏翰    時間: 2023-7-11 11:02

list=["忠","孝","仁","愛","信","義","和","平"]
for s in list:
    print(s,end=" ")
作者: 張育維    時間: 2023-7-11 11:04

  1. listD=["氫","鋰","鈉","鉀","銣","銫","砝"]
  2. listE=[1,2,3,4,5,6,7]
  3. for i in listD:
  4.     print(i,end=" ")
  5. print()
  6. for i in range(7):
  7.    print(f"元素週期表第{listE[i]}個是{listD[i]}")
複製代碼

作者: 董恩瑞    時間: 2023-7-11 11:45

list=["忠","孝","仁","愛","信","義","和","平"]
for s in list:
    print(s,end=" ")
作者: 盧承新    時間: 2023-8-3 10:54

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

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

作者: 盧芷萱    時間: 2023-8-3 10:54

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

作者: 高士涵    時間: 2023-8-3 10:54

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

作者: 呂宗晉    時間: 2023-8-3 10:55

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

作者: 張子搴    時間: 2023-8-3 10:55

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

作者: 鄧維成    時間: 2023-8-3 10:55

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

作者: 得銓    時間: 2023-8-3 10:56

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

作者: 陳珺    時間: 2023-8-3 10:56

list=["忠","孝","仁","愛","信","義","和","平"]
for i in list:
    print(i,end=i)
作者: 李逢翔    時間: 2023-8-3 10:56

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

作者: 張絜晰    時間: 2023-8-3 10:56

  1. list=["a","b","c","d","e","f","g","h"]
  2. for s in list:
  3.     print(s,end=" ")
複製代碼





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