n = int(input()) #fixed length
l = input().split()
我想要的列表应该作为一行输入给出,所以我不知道范围将如何帮助?
使用len()检查长度并引发错误。
if len(l)>n:
raise Exception('Please give only {} inputs'.format(n))
您可以使用len来确定列表或元组的大小。
if len(l) > n: # assuming n is the max size
print("List too large")