I have written a code that randomly generated 100 numbers and puts in all in an array. I want to know of a command, or code, that would tell me how many 5's (or any number for that matter) are in the array after it is generated.
This is my code so far>>
import random
x = 1
def rand():
return random.randrange(0,10,1) #a random number between 0 and 9
myList = []
while (x != 100):
x=x+1
y = rand()
myList.append(y)
and at the end I want a command to give me the number of 5's. Something like>>
getNumber.of(5) from myList
I also want an output that shows location also. Something like>>
7 (5's) at: myList[12], myList[20], myList[27], myList[33], myList[59], myList[74], myList[90]