def func(lst):
fac_lst = ([])
try:
for x in lst:
i = 0
fac = 1
while i < x:
fac *= (x - i)
i += 1
fac_lst.append(fac)
return fac_lst
except TypeError:
return "Please input only numbers!"
except IndexError:
return "Please stay within the index!"
lst = ([1, 2, 3, 4, 5, 6, 7, 8])
print(func(lst))
I think this is what you're looking for. Best of luck.