Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
I know that I can display a single string in the terminal window like print("example") (or similarly with a string in a variable), and I know how to open text files and write to them. I also know ...
#1: Initial revision
How can I output / display multiple values, with controlled spacing, without building a string?
I know that I can display a single string in the terminal window like `print("example")` (or similarly with a string in a variable), and I know how to open text files and write to them. I also know that I can create a "formatted" string, that contains multiple pieces of information, [in a variety of ways](https://software.codidact.com/posts/289251). So if I want to output multiple things, obviously there's the option of creating that string and outputting it. But sometimes for more complex code, it seems impractical to build a string ahead of time. I experimented a little, and found that: * if I just call `print` multiple times, each value appears on a separate line. * if I use the `write` method of an open file multiple times, the values appear consecutively, without any space in between. A lot of the time, neither of these is what I want. For example, I might want to separate each new item with a space as they're output. More generally, I'd like to be able to control the formatting. What options do I have for doing this? Are there any "gotchas" I should be aware of?