(May-28-2020, 04:37 PM)Harambe Wrote: import random
number=sorted(random.sample(range(1,1501)))
for i in range(100):
letters=sorted(random.sample('abcdefgh',4))
print(str(number) + '.' + ' ' + ','.join(letters))
Error in 2nd line. I dont know why. Range command includes start, stop and count value. Didnt write 1 as count cause it is given automatically.
It is the random.sample() function that needs an additional argument, not range(). Remember that random.sample() is going to return a list, and the second argument when calling it is the number of items you want included in that list. In this case, you want a list of 100 random numbers so:
number = sorted(random.sample(range(1, 1501), 100))
In your print statement, you want to print individual items from the list variable "number" (using the index value) rather than the whole list at once, so use "number[i]" here. Also, you can combine the period and space into one string rather than including each of them separately:
print(str(number[i]) + '. ' + ','.join(letters))