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 email@example.com. 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
- __name__ (A Special variable) in Python
- __file__ (A Special variable) in Python
- Python | Check if variable is tuple
- Python | Check if a variable is string
- Python | Variable list slicing
- Python - Variable Operations Dictionary update
- Python Program to swap two numbers without using third variable
- Python | Accessing variable value from code scope
- Different ways to access Instance Variable in Python
- Python | Using variable outside and inside the class and method
- Python | Set 6 (Command Line and Variable Arguments)
- Python | setting and retrieving values of Tkinter variable
- Full domain Hashing with variable Hash size in Python
- Single and Double Quotes | Python
- Python | super() in single inheritance
- Python | Associating a single value with all list items
- Python | Split a list having single integer