-1

Sorry if title is confusing. I am using python code example:

a = print("_ ")

b = print("_ ")

c = print("_ ")

x = print("_ ")

y = print("_ ")

z = print("_ ")

I am trying to make these print on the same line, like this "_ _ _ _ _ _" I have tried doing

sys.stdout.write("\033[F")

but it isnt working. Thanks in advance.

Withnail
  • 3,128
  • 2
  • 30
  • 47
  • Possible duplicate of [How can I print variable and string on same line in Python?](https://stackoverflow.com/questions/17153779/how-can-i-print-variable-and-string-on-same-line-in-python) – Withnail Dec 06 '18 at 17:31
  • You're aware that this might get downvoted, because it's not a great question - so why ask it in that format? There are a lot of answers already on stack overflow for this basic problem. Have a look at questions for multiple variables print on the same line, and you'll see what I mean. – Withnail Dec 06 '18 at 17:36
  • I have been looking and I haven't found the answer. – user10756082 Dec 06 '18 at 18:04
  • My duplicate suggestion is one. – Withnail Dec 06 '18 at 18:06
  • 2
    What do you expect `a` to be in the above? `print` will always return `None`. – Patrick Haugh Dec 06 '18 at 19:20
  • Possible duplicate of [How to print without newline or space?](https://stackoverflow.com/questions/493386/how-to-print-without-newline-or-space) – mkrieger1 Dec 06 '18 at 19:36

1 Answers1

1

There are a few problems with this question, as indicated in the comments, and I think that the core of the question (How do I print stuff on the same line?) is answered elsewhere.

The main problem you're having here though is that, as Patrick said, you're assigning the variables the output of the print function, which doesn't return anything. It puts the values of the objects you pass it into the text stream file. If there's no file, it passes the value to sys.stdout, so there's nothing to capture into your variable. You would need to do it in the format

a = "_ "

etc...

Then do

print(a,b,c,d...)

The documentation for the print function is here - it might be worth your while taking in a tutorial or some time with the python docs themselves, as it's one of the first things covered in the tutorials - printing, variables and functions.

Withnail
  • 3,128
  • 2
  • 30
  • 47