string=["格林童话","挪威的森林","web前端设计css及JavaScript","计算机运用及基本原理"]
k=0
for i in string:
if(len(i)>10):
string[k]=string[k][:9]
k+=1
print(string)
运行结果:
string=["格林童话","挪威的森林","web前端设计css及JavaScript","计算机运用及基本原理"]
k=0
for i in string:
if(len(i)>10):
string[k]=string[k][:9]
k+=1
print(string)
运行结果: