0

This question is about getting the string join method to work.

This code, from what I can see of python 3 documentation, should work:

str = "-";
seq = ("a", "b", "c"); # This is sequence of strings.
print str.join( seq );

But it's generating a syntax error for me:

  File "b.py", line 5
    print str.join( seq );
            ^
SyntaxError: invalid syntax

What am I missing?

smartyollie
  • 161
  • 3
  • 9
  • It is not the `str.join()` call that caused the syntax error. Note: try not to use built-in names for variables, you are masking the `str` type. – Martijn Pieters Mar 06 '15 at 17:32
  • If you didn't follow the link, python 3 `print` is a function, so requires parentheses around the argument list. Bad idea to call a string `str`. No need to end a statement with semi-colons in Python, unless you really enjoy typing semi-colons (believe me, the novelty will wear off). – cdarke Mar 06 '15 at 17:39

0 Answers0