Python Forum

Full Version: Don't understand example code from a textbook
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm just starting to learn python and I'm using a textbook to learn. For demonstrating for loops the book used this bit of code:

print('My name is')
for i in range(5):
 print('Jimmy Five Times (' + str(i) + ')')
I understand it for the most part except for the + operators in front of and behind of str(i). I know what they are, but for some reason I'm having a hard time figuring out why they are both needed in that bit of code. The textbook isn't explaining it.
string + string in Python, is string concatenation. ie: two strings separated by a plus sign are combined into a new string.