print automatically adds a newline character after the string you've entered, this is why it prints each number on a different line. To change this behavior, you must change end
parameter on the function call.
for a in range(1,11):
print(a, end=' ')
Edit:
The end
parameter holds a string which gets printed after the string you've entered. By default it's set to \n
so after each print, \n
is added:
print("Hello!") # actually prints "Hello!\n"
You can change the parameter to anything you like:
print("Hello!", end="...") # prints "Hello!..."
print("Hello!", end="") # prints "Hello!"