我被要求让程序生成 15 个随机整数的数组,然后要求用户输入数组中的数字并显示一条消息,说明它在数组中,但是,我收到错误反而。
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.")
输出:
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()
慕田峪9158850
萧十郎
万千封印
相关分类