char1 = ” “
for i in range(5) :
#從0開始,間距1,持續5次=> 0 1 2 3 4
#只輸入一個參數,預設從0開始,間距1
char1 = char1 + str(i) + ” “
print(char1)
#####
char2 = ” “
for j in range(0,4) :
#從0開始,間距1,持續4次=>0 1 2 3
#從0開始,間距1,到4為止,4不算=> 0 1 2 3
char2 = char2 + str(j) + ” “
print(char2)
#####
char3 = ” “
for k in range(1,4) :
#從1開始,間距1,持續3次=>1 2 3
#從1開始,間距1,到4為止,4不算
char3 = char3 + str(k) + ” “
print(char3)
#####
char4 = ” “
for l in range(0,10,2) :
#從0開始,到10結束,10不算,間距2=>0 2 4 6 8
char4 = char4 + str(l) + ” “
print(char4)
#####
char5 = ” “
for m in range(1,10,2) :
#從0開始,到10結束,間距2=>1 3 5 7 9
char5 = char5 + str(m) + ” “
print(char5)
Spyder執行結果: