I have been asked to get the program to generate an array of 15 random integers and then to ask the user to input the number from the array and for it to display a message saying that it was in the array, however, I get an error instead.
import numpy as ny
randnums = ny.random.randint(1,101,15)
print(randnums)
target = int(input("Please pick a random number: "))
for counter in range(0,15):
while target != randnums:
print("This number is not in the list")
target = int(input("Please pick a random number: "))
else:
if target == randnums:
print("The number" , target , "has been found in the list.")
Output:
Traceback (most recent call last):
File "python", line 9, in <module>
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
Aucun commentaire:
Enregistrer un commentaire