I have a list containing a variable number of items,
list_example = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ...]
and I'd like to format it into a string as follows:
0 1 2 3 4 5 6 7 8 9 ...
Currently, I'm doing this using a simple for
loop:
string = ""
for i in range(len(list_example) - 1):
string += str(list_example[i]) + " "
string += str(list_example[-1])
It works well, but I feel like it must be a better (more compact) way of achieving that. If anybody knows how to do it, please, let me know!