Python String Concatenation - concatenating '\n'

Viewed 37827

I am new to Python and need help trying to understand two problems i am getting relating to concatenating strings. I am aware that strings can be added to concatenate each other using + symbol like so.

>>> 'a' + 'b'
'ab'

However, i just recently found out you do not even need to use the + symbol to concatenate strings (by accident/fiddling around), which leads to my first problem to understand - How/why is this possible!?

>>> print 'a' + 'b'
ab

Furthermore, I also understand that the '\n' string produces a 'newline'. But when used in conjunction with my first problem. I get the following.

>>> print '\n' 'a'*7

a
a
a
a
a
a
a

So my second problem arises - "Why do i get 7 new lines of the letter 'a'. In other words, shouldn't the repeater symbol, *, repeat the letter 'a' 7 times!? As follows.

>>> print 'a'*7
aaaaaaa

Please help me clarify what is going on.

4 Answers
Related