[Tutor] Concatenating Strings

Jeremy Duenas jduenas23 at gmail.com
Tue May 29 05:12:50 CEST 2012

Thanks for the replays all your responses makes perfect sense looking at it
that way. I agree the example in the book explained it simply, just made no
sense as to why and how it is really used. What ya'll have explained to me
makes sense and thank you. I can see the importance of it now. 



From: brian arb [mailto:brianjamesarb at gmail.com] 
Sent: Monday, May 28, 2012 7:22 PM
To: Jeremy Duenas
Cc: tutor at python.org
Subject: Re: [Tutor] Concatenating Strings


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


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:


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120528/b0c062d5/attachment.html>

More information about the Tutor mailing list