返回列表 發帖

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

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

TOP

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

TOP

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

TOP

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

TOP

list1=["忠","孝","仁","愛","信","義","和","平"]
for i in list1:
     print(i,end=" ")

TOP

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

TOP

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

TOP

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

TOP

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

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

TOP

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

TOP

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

TOP

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

TOP

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

TOP

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

TOP

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

TOP

list=["忠","孝","仁","愛","信","義","和","平"]
for i in list:
    print(i,end=i)

TOP

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

TOP

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

TOP

返回列表