Board logo

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

作者: 鄭繼威    時間: 2022-7-19 02:25     標題: for 迴圈 (一)

#range(start,stop,step)
#range(1,6)->[1,2,3,4,5]


直向顯示第1名~第5名

  1. for i in range(1,6):
  2.     print("第",i,"名")
複製代碼

作者: 鄭繼威    時間: 2022-7-19 14:10

  1. list1=[0,1,2,3,4,"apple","忠",9,999]

  2. for kevin in list1:
  3.     print(kevin,"嗨")
  4.    
  5. #range(1,100)->[1,2,3,4,5]
  6. for i in range(1,6):
  7.     print(f"第{i}名")
  8. list2=[1,2,3,4,5]
  9. for i in list2:
  10.     print(f"第{i}名")
複製代碼

作者: 盧宥廷    時間: 2022-7-19 14:13

  1. for i in range(1,6):
  2.     print(f"第{i}名")
複製代碼

作者: 盧宥熏    時間: 2022-7-19 14:15

  1. list=[1,2,3,4,5]
  2. for a in list:
  3.     print(f"第{a}名")
  4.    
複製代碼

作者: 陳羨芮    時間: 2022-7-19 14:15

  1. for i in range(1,6):
  2.     print("第",i,"名")
複製代碼

作者: 李宥廷    時間: 2022-7-19 14:17

  1. for a in range(1,6):
  2.     print("第",a,"名")
複製代碼

作者: 張晏齊    時間: 2022-7-19 14:19

  1. # -*- coding: utf-8 -*-
  2. """
  3. Spyder Editor

  4. This is a temporary script file.
  5. """
  6. list1 =[0,1,2,3,4,"apple","忠",9,999]   


  7. for Martin in list1:
  8.     print(Martin,"嗨")
  9. #range(1,100)->[1,2,3,4,5]
  10. for i in range(1,6):
  11.     print(f"第{i}名")
  12. list2=[1,2,3,4,5]
  13. for i in list2:
  14.     print(f"第{i}名")
複製代碼





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