End 在循环中的 print() 函数中不起作用
我正在尝试执行以下代码,但它没有给我任何输出。当我从打印中删除结尾时,它会给我输出,但集合中的每个元素都在新行上打印。为了摆脱这个问题,我在打印中使用 end 但它不起作用。请帮忙!
myset={'Haider','Wali','Aamir'}
for x in myset:
print(x,end='')
I am trying the following code to execute which is giving me nothing in output. And when I remove end from print then it gives me the output but every element of the set is printing on new line. To get rid of this I am using end in print but its not working. PLEASE HELP!!
myset={'Haider','Wali','Aamir'}
for x in myset:
print(x,end='')
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
由于代码显示不清晰,并且评论中无法附加图像,我写下这个答案,如下:
以下是代码结果的图像。
As a code is not clearly shown and an image cannot be attached on a comment, I write this answer, as follows:
Following is an image of the result of the code.
我认为您在结束参数中缺少一个空格。尝试 print(x, end=' ')
I think you are missing a space in the end parameter. Try print(x, end=' ')