Parentheses and quotation marks in output

python print parentheses in string
python add parentheses to string
python printing a list without the brackets and single quotes
python print brackets
python string with brackets
python return parentheses
how to make parentheses in python
parentheses meaning in python

Sometimes when I use the print function, parentheses and quotation marks appear in the output. I'm using Python 3.4 and writing the code in Sublime Text on a mac.

Here's an example

Input:

a=2
print("a",a)

Output:

('a', 2)

I'd like to show only a and 2.

Thanks in advance!

You appear to be using Python 2.

a = 2
print("a %i" % a)

should give you the results you're looking for. Or, using the newer str.format() method:

print("a {}".format(a))

In Python 3, your statement print("a",a) will work as expected. Check your build system in Sublime to make sure you're calling python3 instead of python. Run this code to see what version is actually being used:

import sys

print(sys.version)

To create a Python 3 build system, open a new file with JSON syntax and the following contents:

{
    "cmd": ["python3", "-u", "$file"],
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.python"
}

Save the file as Packages/User/Python3.sublime-build where Packages is the folder opened when you select Sublime Text -> Preferences -> Browse Packages.... You can now select Tools -> Build System -> Python3 and, assuming python3 is in your PATH, you should build with the correct version.

If the build fails with an error that it can't find python3, open Terminal and type

which python3

to see where it's installed. Copy the entire path and put it in the build system. For example, if which python3 returns /usr/local/bin/python3, then the "cmd" statement in your .sublime-build file should be:

"cmd": ["/usr/local/bin/python3", "-u", "$file"],

4.splat why there are parentheses ?, but i wonder why there are parentheses and single quotation marks? why doesn't it looks like. Your favorite actors are: Michael Palin, John Cleese, Graham  Less commonly, single quotation marks are used in place of parentheses, in which case the translation is not set off with commas. Also, any punctuation otherwise required by the structure of the sentence is placed outside the single quotation marks.

Are you sure you are executing it on Python 3 interpreter? In Python 2 print is an statment so it takes no parentheses

print ("a", 2) // parentheses are interpreted as a tuple constructor
>>> ('a', 2)

is the same as

print tuple(["a",2])
>>> ('a', 2)

or in Python 3:

print( ("a",2) )
>>> ('a', 2)

Quotation Marks, Quotation marks also set off the titles of things that do not normally stand by themselves: In the United States, periods and commas go inside quotation marks 'tx_send' determines whether the signal will be output through TX Output Port. But that's not right either. Your number three is. The answer to build outwards: Juno is in quotation marks; then the parenthetical phrase is in brackets; then the sentence finishes with a full-stop. I love Diablo Cody (Oscar-winning writer of 'Juno'). And the task is made easier if the title is written in italics, as is customary:

I think you are using python 2. In python 2 you don't need parentheses and directly write code as below

print "a", a

Quotation marks, Commas and periods that are part of the overall sentence go inside the quotation marks, even though they aren't part of the original quotation. Correct. “The best  Generally, periods (to signify the end of sentences) will always come after apostrophes. Quotation marks and parentheses will go outside of the period, but apostrophes go inside.

Understanding Python Basics, Mixing your quotation marks back and forth makes the code harder for humans to read. Sometimes you need to output a character string that  Quotation Marks in Parenthetical Statement. When identifying an acronym, I have always simply placed that acronym or abbreviation in parenthesis following the phrase. For example: Los Angeles International Airport (LAX).

Strings, Strings are contained within a pair of either single quotation marks '' or double quotation marks "". Let's say you're trying to use quotation marks inside a string. but keep the middle spaces ".trim();. OUTPUT. "but keep the middle spaces"  Using Unmatched Quotation Marks and Parentheses with %STR and %NRSTR If the argument to %STR or %NRSTR contains an unmatched single or double quotation mark or an unmatched left or right parenthesis, precede each of these characters with a % sign.

Macro Quoting : Using the %STR and %NRSTR Functions, See "Using Unmatched Quotation Marks and Parentheses with %STR and %​NRSTR" The string &myvar appears in log output, instead of the variable value. To place quotation marks in a string in your code. In Visual Basic, insert two quotation marks in a row as an embedded quotation mark. In Visual C# and Visual C++, insert the escape sequence \" as an embedded quotation mark. For example, to create the preceding string, use the following code.

Comments
  • This is Py2 output ... Mac is cheating on you
  • After installing python3 using the default installer from python.org, you will have two versions of python on your system: the pre-installed python 2 which is named python in your path and python 3 that have the name python3 in your path. Python 3 can be executed by typing python3 in the terminal and python 2 launches when simply typing python
  • Not to contradict your point. The print("a",a) statement is correct but in py2 the O/p is a tuple. It has to work in Py3