-3

I'm new to Python and was trying out some programs. Got stuck in this one.

Python 3.2.5 (default, May 15 2013, 23:06:03) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> def buildConnectionString(params):    """Build a connection string from a       dictionary of parameters.
Returns string."""
return ";".join(["%s=%s" % (k, v) for k, v in params.items()])
if __name__ == "__main__":
    myParams =  {"server":"mpilgrim", 
                 "database":"master", 
                 "uid":"sa", 
                 "pwd":"secret" 
                }
print buildConnectionString(myParams)

SyntaxError: invalid syntax
>>> 
musicakc
  • 488
  • 1
  • 4
  • 15
  • 1
    Please check the formatting of your code, and correct it. Indentation is important in Python - if it was just a mistake copy/pasting it into SO, then just hit edit below your post and correct it. Please also post the full stack trace and error you received. – Gareth Latty Oct 06 '13 at 09:28
  • 4
    It's worth noting you don't need backslashes for line continuation when you are inside a set of brackets. – Gareth Latty Oct 06 '13 at 09:31

1 Answers1

1

Print is a function in python 3 so change

print buildConnectionString(myParams)

To:

print(buildConnectionString(myParams))
K DawG
  • 13,287
  • 9
  • 35
  • 66