I'm trying to write a program that generates a list of ten random integers from 1-5 inclusive, then prints the number each time each integer repeats. Then prints a second list with the duplicates removed. Right now I'm having an issue even getting the first list to generate at all. I keep getting TypeError: 'int' object is not iterable
This is what I have so far:
def randomTen():
"""return list of ten integers and the number of times each one
appears"""
firstList= []
for num in range(1,11):
x= int(random.randint(1,6))
list1= firstList.append(x)
print(list1)
append, notextend.Noneuntil you return something with thereturnkeyword.firstList = [random.randint(1,6) for num in range(10)]is a more "pythonic" way to do the same.