Кто-нибудь знает, почему это приводит к тому, что аргумент TypeError: int () должен быть строкой, байтовоподобным объектом или числом, а не «списком»?
user_input = input("Please enter a list of numbers here: ")
lst4 = user_input.split()
def sum67(lst4):
segment_one = []
segment_two = []
for i in range(len(lst4)):
if int(lst4[i]) == 6:
segment_one.append(int(lst4[0:i]))
for i2 in range(len(lst4)):
if int(lst4[i2]) == 7 and i2 > len(segment_one):
segment_two.append (int(lst4[i2+1:]))
complete_list = segment_one + segment_two
total = 0
for groups in complete_list:
for value in groups:
total += value
return total
print(sum67(lst4))
Вот полный ввод и сообщение об ошибке:
Please enter a list of numbers here: 2 3 4 6 7 8
Traceback (most recent call last):
File "/Users/lucasjacaruso/Desktop/Calc Course/Powers_list.py", line 21, in <module>
print(sum67(lst4))
File "/Users/lucasjacaruso/Desktop/Calc Course/Powers_list.py", line 9, in sum67
segment_one.append(int(lst4[0:i]))
TypeError: int() argument must be a string, a bytes-like object or a number, not 'list'