Consider below two Python code snippets in Python 2.x.
There is no difference between code 1 and code 2 in case of single variable in Python 2.X, but in case of multiple variables, variable with brackets -() is treated as “tuple”.
For multiple variable:
- “print variable” prints the variables without any brackets ‘()’ and splitted by a space
- “print(variable)” prints the variables with brackets ‘()’ and splitted by a coma ‘,’ so it’s treated as a tuple.
In Python 3.0, the print statement is changed to print() function. Below are equivalent codes in Python 3.0.
This article is contributed by Arpit Agarwal. If you like GeeksforGeeks and would like to contribute, you can also write an article and mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above
- Python | Replace multiple occurrence of character by single
- Python | Convert a list of multiple integers into a single integer
- __name__ (A Special variable) in Python
- Python | Variable list slicing
- Python | Set 6 (Command Line and Variable Arguments)
- Python | Using variable outside and inside the class and method
- Python | super() in single inheritance
- Python | Associating a single value with all list items
- Python | Split a list having single integer
- Transpose a matrix in Single line in Python
- A single neuron neural network in Python
- Multiplication of two Matrices in Single line using Numpy in Python
- Python code to move spaces to front of string in single traversal
- Rename multiple files using Python
- Python | Intersection of multiple lists