BASH "echo -n value" in Python 2.6/2.x or Python 3.x within a loop - single line without space
<p>Like in BASH, I can use "echo -n" within a loop and print all elements in an array (or list in Python) in a single line without any space " " character. See the "<strong>echo -n</strong> value" below in second for loop.</p>

<pre><code>Arun Sangal@pc MINGW64 ~
$ a=(1 2 33 four)

Arun Sangal@pc MINGW64 ~
$ for v in ${a[@]}; do echo $v; done
1
2
33
four

Arun Sangal@pc MINGW64 ~
$ for v in ${a[@]}; do echo -n $v; done
1233four
Arun Sangal@pc MINGW64 ~
$ for v in ${a[@]}; do echo -n "$v "; done
1 2 33 four
</code></pre>

<p>How can I do the same in Python using <strong>for</strong> loop while iterating each list value.</p>

<p><strong>PS</strong>: I don't want to use "".join(list). Also, it seems like "".join(list) will WORK only if my list in Python has values as "strings" type then "".join(list) will work (like BASH <strong>echo -n</strong>) but if the list has Integer aka non-string values (for ex: as shown in the list <strong>numbers</strong> in the code below), "".join(numbers) or "".join(str(numbers)) still didn't work (like BASH <strong>echo -n</strong>); in this case, even though I used <strong>print num,</strong> in the loop, it still introduced a space " " character.</p>

<p>I'm trying to use <strong>print value,</strong> (with a command) but it's introducing a space " " character.</p>

<p>In Python 2.x, the following code is showing:</p>

<pre><code>numbers  = [7, 9, 12, 54, 99] #"".join(..) will NOT work or print val, will not work here
strings  = ["1", "2", "33", "four"] #"".join(..) will work as values are strings type.

print "This list contains: "

#This will print each value in list numbers but in individual new line per iteration of the loop.
for num in numbers:
    print num

print ""
print "".join(str(numbers))
print "".join(strings)

#PS: This won't work if the values are "non-string" format as I'm still getting a space character (see output below) for each print statement for printing num value
for num in numbers:
    print num,
</code></pre>

<p>output as:</p>

<pre><code>This list contains: 
7
9
12
54
99

[7, 9, 12, 54, 99]
1233four
7 9 12 54 99
</code></pre>

<p>What I'm looking for is, how can I print all elements of list <strong>numbers</strong> (as shown below) using for loop and a print statement in a single line when the list has non-string values?</p>

<pre><code>79125499
</code></pre>