[英]Cannot print output on the same line
I want my output to print on one line and there should be gap after the input taken by the use.我希望我的 output 打印在一行上,并且在用户输入后应该有间隙。
i = 1
x = int(input("enter a number to loop" ))
while(i<=x):
print('\n',i, end= " ")
i += 1
for my code, my output is not on the same line.对于我的代码,我的 output 不在同一行。 how to have an output printed on one line.如何在一行上打印 output。
You added a \n in your print function..您在打印 function.. 中添加了一个 \n
i = 1
x = int(input("enter a number to loop\n"))
while(i <= x):
print(i, end=" ")
i += 1
This should solve your issue这应该可以解决您的问题
i = 1
x = int(input("enter a number to loop " ))
print("\n")
while(i<=x):
print(i, end= " ")
i += 1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.