Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Data Science by (18.4k points)

I am new to python and I am stuck with the error, any help will be appreciatable:

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

1 Answer

0 votes
by (36.8k points)

Print statement in python 3 is a function so change this:

print buildConnectionString(myParams)

To:

print(buildConnectionString(myParams))

Click on the link for more information

If you are a beginner and want to know more about Data Science the do check out the Data Science course

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...