将字符串的一部分附加到列表中,然后尝试打印列表,将显示“无”

时间:2019-07-31 20:25:33

标签: python printing append substring slice

我试图通过.append将字符串的片段添加到列表中,但是当我尝试打印列表时,Python打印“ None”,为什么会发生这种情况?我需要使用索引来“播放”同一字符串的其他片段,该如何实现?

#I need to use the "n" variable to set the lenght of the slice
n = 14

a = "We'll just flyyyyyy awaaaaaay from here, aaaaaaaaaanywhere!!"
f = []
f = f.append(a[0:n])
print(f)

0 个答案:

没有答案