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
- Protected variable in Python
- Python | Check if a variable is string
- Python | Check if variable is tuple
- __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 | Accessing variable value from code scope
- Python | setting and retrieving values of Tkinter variable
- Single and Double Quotes | Python
- Python | super() in single inheritance
- A single neuron neural network in Python
- Python | Associating a single value with all list items