Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

How do I make this piece of code tell you how many 7s there are?

+1 vote
asked Feb 11, 2021 by Christopher Bartholf (290 points)
import random
mylist = []

for i in range(0,10):
    x = random.randint(1,7)
    mylist.append(x)
print(mylist)

1 Answer

0 votes
answered Feb 12, 2021 by Jeff The Chicken (2,920 points)

Use the count method:

import random
mylist = []

for i in range(0,10):
    x = random.randint(1,7)
    mylist.append(x)
print (mylist)
print (mylist.count(7))
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...