Python3,Day5,while,for,break双循环。
1.代码实现s = "python"while s != "":print(s)for c in s:if c == "t":breakprint(c,end='')s = s[:-1]print()2.运行结果pythonpypythopypythpypytpypyp...
·
1.代码实现
s = "python"
while s != "":
print(s)
for c in s:
if c == "t": #打印出t之前的字母
break
print(c,end='') #不换行,直到break结束
s = s[:-1] # 逐个减一
print()
2.运行结果
python
py
pytho
py
pyth
py
pyt
py
py
py
p
p
更多推荐
已为社区贡献1条内容
所有评论(0)