From db22bd3547c1484921cf96d4a33043e63b95c50b Mon Sep 17 00:00:00 2001 From: Nayan Chawla <33131849+NNChawla@users.noreply.github.com> Date: Sun, 12 May 2019 16:33:15 -0500 Subject: [PATCH] Python 3 Change (#28596) Included difference in python 3 vs python 2 --- guide/english/python/range-function/index.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/guide/english/python/range-function/index.md b/guide/english/python/range-function/index.md index 0ae5fe8bc6b..a72f5e58918 100644 --- a/guide/english/python/range-function/index.md +++ b/guide/english/python/range-function/index.md @@ -46,6 +46,20 @@ for i in range(3, 12, 2): 11 ``` +#### Changes in Python 3 +In Python 3, by default the range function will not generate a list of integers when assigned to a variable. Instead, the user must manually convert it to a list. + +#### Example usage in Python 3 + ```py +numbers = list(range(1, 10)) +print(numbers) + ``` + +#### Output + ``` +[1, 2, 3, 4, 5, 6, 7, 8, 9] + ``` + ## Input and Output types **Input** - All arguments to the range function must be integers (either built-in `int` or any object that implements the `__index__` special method).