s = input()
k=input()
def string():
n=0
index=0
while (k+n)<len (s):
string= s[index:(k+n)]
index+=1
n+=1
return string
我想回退输入字符串的子字符串
首先缩进代码
s = input()
k=input()
def string():
n=0
index=0
while (k+n)<len (s):
string= s[index:(k+n)]
index+=1
n+=1
return string
然后,确保在调用函数时使用print函数,例如print(string())