Thread: Python 3.0
View Single Post
Old 02-03-2009, 01:00 PM   #12 (permalink)
MrGraham
The Next Orange
 
MrGraham's Avatar
 
Join Date: Sep 2006
Posts: 1,322
+11 Internets
I'm running through the Python intro for fun as well. My programming experience is limited to HTML, Coldfusion, PHP, and SQL, so this question might be stupid for people who have worked with C.

Question - the following lines are from one of the first pages of the tutorial.
Code:
>>> word = 'Help' + 'A'
>>> word
'HelpA'
>>> '<' + word*5 + '>'
''
Why does the last line have to have the " + "'s around word*5 to work?
Code:
>>> word*5
'HelpAHelpAHelpAHelpAHelpA'
>>> ''
''
>>> '<'word*5'>'
SyntaxError: invalid syntax (, line 1)
... even with the code tag it's still omitting some.

An Informal Introduction to Python — Python v3.1a0 documentation

That's the page, it's like halfway down, section on concatenates.

Don't understand why '<' + word*5 + '>' works but '<'word*5'>' does not.

Last edited by MrGraham; 02-03-2009 at 01:19 PM..
MrGraham is offline   Reply With Quote

 
Uberguilds Network