- Printing values on screen
- User input
- Printing values
Python 2 | Python 3 |
print“Hello” | print(“Hello”) |
In python 2, to print a value you just need to apply quotes after
print syntax because print behaves as an operator, which means it
operates on whatever comes after it. In python 3, print is a function
that takes arguments, So parenthesis are must.
So remember whenever you see error like this
>>>print“Lucious”File”<stdin>”,line1print“Lucious”^SyntaxError:Missingparenthesesincallto’print’ It means you were trying use python 2 syntax in python 3. 2. User Input Next
difference you should know is about user input used to take values from
user. In python 2 the raw_input()function was used but in python 3 it
is removed and is replaced by input()
It means for both strings and integers you will use this functions only if working in python 3.
How to use Syntax Differences between Python 2 and Python 3 | Softcrayons IT Training Tutorial
No comments:
Post a Comment