1.range 運算結果: 2. 運算結果: ...
1.range
a = range(0 ,100 , 5) #創建>=0,<100的連續數字,步長為5 for b in a: print(b)
運算結果:
0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 Process finished with exit code 0
2.
text = input("請輸入:") print("您輸入的數是:",text) a = len(text) print("有",a,"位") r = range(0,a) for b in r: print(b,text[b])
# 也可以簡寫
###
text = input("請輸入:")
for b in range(0,len(text)):
print(b,text[b])
###
運算結果:
請輸入:jaslkfaj 您輸入的數是: jaslkfaj 有 8 位 0 j 1 a 2 s 3 l 4 k 5 f 6 a 7 j Process finished with exit code 0