我希望我的程序打印字符串「welcome」中的其他每個字母。 像:Python:使用循環更改範圍位置
e
c
m
這裏是我到目前爲止的代碼:
stringVar = "welcome"
countInt = 7
count = 0
oneVar = 1
twoVar = 2
showVar = stringVar[oneVar:twoVar]
for count in range(countInt):
count = count + 1
oneVar = oneVar + count
twoVar = twoVar + count
print(showVar)
雖然只顯示第2個字母 「e」。 我如何獲得變量oneVar和twoVar來更新,以便範圍在循環的持續時間內發生變化?
他不希望第二個字符:) – thefourtheye
沒我把一些錯誤要麼 ?我想我正在解釋他爲什麼只得到第二個角色。 –
他預計只有'e c m' – thefourtheye