#range(start=0,stop,step=1)
#range(1,6)->[1,2,3,4,5]
#for i in list資料
試宣告兩個串列,一個存放班級名稱,一個存放人數,搭配 for 迴圈顯示五年級各班人數,執行畫面如下:
- list1=["忠","孝","仁","愛","信","義","和","平"]
- list2=[28,27,27,26,28,29,30,27]
- for i in range(8):
- print("五年{}班有{}人".format(list1[i],list2[i]))
複製代碼 |