B
B
Bogdan2021-11-14 18:59:53
Python
Bogdan, 2021-11-14 18:59:53

How to fix TypeError: unsupported operand type(s) for +: 'int' and 'str'?

s = input("введи штрих код")
pudge = 0
a =''
b =''
for i in range(0,len(s),2):
    a += s[i]
for i in range(1, len(s), 2):
    b += s[i]
gg = list(a)
gg1 = list(b)
print(sum(gg))
print(gg1)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Gornostaev, 2021-11-14
@bolossev666

Obviously don't add numbers to strings.

B
Black back, 2021-11-15
@bekss

int(value) + int(value) or str(value) + str(value)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question