0

When we write: numbers = range(10) print(numbers) the output is: range(0,10) Why?

5th Jul 2017, 5:07 PM
Bedabivrab Rajkhowa
Bedabivrab Rajkhowa - avatar
5 Answers
+ 1
It creates a random number between 0 and 10. It defaults to 0 because you didn't specifiy the min range.
5th Jul 2017, 5:09 PM
AgentSmith
+ 1
range(10) in Python is an object, the generator to be precise. it is not "random number". to get the numbers that this generator is supposed to create you need numbers = list (range ( 10 ) )
6th Jul 2017, 10:08 AM
yuri
0
numbers = list(range(10)) print(numbers) FYI this example in jupyter will give a list call error not the correct code to teach
10th Feb 2023, 4:34 PM
Dwayne Morris
Dwayne Morris - avatar
0
Write a sample c program that will display 10
3rd Mar 2024, 2:17 PM
Daniel Worugura
Daniel Worugura - avatar