【问题标题】:not the desirable output不是理想的输出
【发布时间】:2022-12-04 12:35:29
【问题描述】:

the expected out put was

1 1
2 2
3 3
4 4
5 5

but the output I got is

1
1 2
2 3
3 4
4 5
5 
for num in numlist:
    print(num)
    print(num,end=\' \')

I tried to execute this python code in python interpreter and got the wrong output

  • This should be extremely easy to debug on your own. The bug is that you are printing a newline with the first print and omitting one in the second one, where apparently you wanted the opposite.
  • can you please explain why does it omitting on in the second one?

标签: python python-3.x for-loop


【解决方案1】:
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-04-24
  • 2018-01-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多