{article Examples__Python 3.4 }{title} {text}{/article}

 

Removing the space at the end of its arguments

You can also customize the separator between items, e.g.:

ride = "Airplane"
print("I like to ride in a ", ride, '!');




To avoid that space you will need to explicitly specify the 'sep' keyword.

print ("I like to ride in a ", ride, "!", sep="") # Note the explicit sep=""

output = "".join(["I like to ride in a ",ride,"!"])

print(output)

 

 

{source}
<!-- You can place html anywhere within the source tags -->
<pre class="brush:py;">
Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:45:13) [MSC v.1600 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> ride = "Airplane"
>>> print("I like to ride in a ", ride, '!'); #To avoid that space you will need to explicitly specify the 'sep' keyword.
I like to ride in a Airplane !
>>> print ("I like to ride in a ", ride, "!", sep="") # Note the explicit sep=""
I like to ride in a Airplane!
>>> output = "".join(["I like to ride in a ",ride,"!"])
>>> print(output)
I like to ride in a Airplane!
>>> print ("Note NO space between Airplane!")
Note NO space between Airplane!
>>>


</pre>

<script language="javascript" type="text/javascript">
    // You can place JavaScript like this

</script>
<?php
    // You can place PHP like this

?>
{/source}