""Hi Thanks for taking time and effort trying to answer this problem. This program generates random numbers and asks user to type in random number which is then mach up against the list of random numbers I'm struggling with a basic program in which numbers need to appear counting up from smallest to highest, and number of times number appears on the list. So far I could only manage with second part ""
import random
numbersList = []
listLen = 100
for i in range( listLen ):
numbersList = numbersList + [ random.randint( 0, 100 ) ]
searchValue = input( "Enter the number to search for: " )
found = False
index = 0
while not found and index < listLen:
if searchValue == numbersList[ index ]:
found = True
else:
index = index + 1
print("The list is:")
print(numbersList)
if found:
print(searchValue, "found at position", index)
else:
print("The value", searchValue, "is not in the list")
Aucun commentaire:
Enregistrer un commentaire