Lists

Christian Gollwitzer auriocus at gmx.de
Mon Sep 15 02:04:03 EDT 2014


Am 15.09.14 04:40, schrieb Seymore4Head:
> nums=range(1,11)
> print (nums)

> I don't understand why the command nums=range(1,11) doesn't work.
> I would think that print(nums) should be 1,2,3 ect.
> Instead it prints range(1,11)

It does work, but in a different way than you might think. range() does 
not return a list of numbers, but rather a generator - that is an object 
which produces the values one after another. But you can transform it 
into a list:

print(list(nums))

should give you what you want.

	Christian



More information about the Python-list mailing list