Issue
I've been trying to solve this Test, but I can't print the numbers in one line using While loop, any ideas?
this is my code
if __name__ == '__main__':
n = int(input())
num = 1
while num <= n:
print(num )
num = num +1
Solution
As drake14w said, you have to use the end keyword argument to avoid automatic line break.
if __name__ == '__main__':
n = int(input())
for i in range(1, n+1):
print(i, end='')
print('')
Answered By - Rodrigo Llanes Answer Checked By - Senaida (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.