Game Development Reference
In-Depth Information
>>> print "Hello",
To print something besides a newline at the end of the print() function in Python 3,
use the keyword argument end :
>>> # Python 3
>>> print("Hello", end="")
The input() and raw_input() Functions
In Python 2, the function to get input from the keyboard is raw_input() . In Python 3,
the input() function does this. You can simply rename the function wherever it appears
in your code.
>>> # Python 2
>>> name = raw_input()
>>> # Python 3
>>> name = input()
The range() Function's Return Value
In Python 2, the range() function returns an actual list with the integers. In Python 3,
the range() function returns a "range object". Both can be used exactly the same way in
for loops:
>>> for i in range(10): # Works in Python 2 and
3
... print(i)
However, if you want to create an actual list of integers in Python 3, you must convert
the "range object" into a list with the list() function:
>>> # Python 2
>>> listOfInts = range(10)
>>> # Python 3
 
Search WWH ::




Custom Search