若想实现,输出字符串最后一个字符时,实现换行效果,以不影响以后的代码
错误案例1
name = "shenzhen"
for s in name:
print(s, end="")
a = ["aa", "bb", "cc", "dd"]
for i in range(len(a)):
print(i, a[i])
输出结果
此情况没有任何意义,不如直接print(name)
错误案例2
name = "shenzhen"
for x in name:
if x == "n":
print(x, end="\n")
else:
print(x, end="\t")
a = ["aa", "bb", "cc", "dd"]
for i in range(len(a)):
print(i, a[i])
输出结果