如何在Python中让两个print函数的输出打印在一行内
4 回答
![?](http://img1.sycdn.imooc.com/57c447e00001f99401000100-100-100.jpg)
qq_Moorsoliloqu_03901774
TA贡献1条经验 获得超0个赞
print函数代入第二个参数 end=' ' 如下:
print(10, end=" ")
print(12)
输出:10 12
![?](http://img1.sycdn.imooc.com/5458477300014deb02200220-100-100.jpg)
临摹微笑
TA贡献1982条经验 获得超2个赞
你应该只在最后print n,而不是每次循环都print n。python使用缩进表示层级关系,参考如下代码,注意print n的位置:
1 2 3 4 5 6 | x = raw_input() n = 0 for i in range(0, len(x)-2): if x[i] == x[len(x)-1]: n = n+1 print n |
添加回答
举报
0/150
提交
取消