Lists

Seymore4Head Seymore4Head at Hotmail.invalid
Sun Sep 14 22:40:14 EDT 2014


import random
nums=range(1,11)
print (nums)
samp=random.sample(nums,10)
top=nums
newlist=nums[::-1]
tail=newlist

for x in range(10):
    print ("Top {:2d}    Tail {:2.0f}  Sample {:2d}
".format(top[x],tail[x],samp[x]))
    
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)

Why does random.sample(nums,10) give me the numbers between 1 and 10.
I am missing something subtle again.




More information about the Python-list mailing list