请问这段代码运行出现什么结果?
s = "PYTHON"while s !="":
for c in s:
if c =="T":
break
print(c,end="")
s = s[:-1] 自己运行一下不就知道了 # PYPYPYPYPYP PYPYPYPYPYP
s = "PYTHON"
while s !="":
for c in s:#遍历字符串,到T停,也就是只打印PY
if c =="T":
break
print(c,end="")
s = s[:-1] #去除最后一个字符,一直循环,直到只剩P,所以最后一个是P,字符串空,跳出
页:
[1]