[Tutor] Concatenating Strings

brian arb brianjamesarb at gmail.com
Tue May 29 04:22:11 CEST 2012


Your right that example from the book is a terrible example the point or
the reason to concatenating strings.

here is a simple usage of where concatenating strings prints out a simple
string as a counter in a loop.

>>> for i in range(5):
...     print(str(i) + ' in for loop')
...
0 in for loop
1 in for loop
2 in for loop
3 in for loop
4 in for loop

On Mon, May 28, 2012 at 10:00 PM, Jeremy Duenas <jduenas23 at gmail.com> wrote:

> I am trying to understand the point behind using the  ‘+’ character when
> trying to concatenate strings. I am new to learning Python and going
> through the book “Python Programming for Absolute Beginners 3rd ed.”  and
> do not understand the point or reason for concatenating strings. The reason
> I do not understand is when experimenting to understand what was being
> taught I wrote:****
>
> ** **
>
> print(“\nThis string” “may not” “seem terr” “ibly impressive”)****
>
> ** **
>
> then wrote:****
>
> ** **
>
> print(“\nThis string” + “may not” + “seem terr” + “ibly impressive”)****
>
> ** **
>
> ** **
>
> and the both printed the same output……so why would I want to use  ‘+’ to
> add strings if there seems to be no reason too?****
>
> ** **
>
> ** **
>
> ** **
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120528/e9c2e344/attachment-0001.html>


More information about the Tutor mailing list