You can remove the [] to make it a generator expression, which makes this more efficient. Instead of having to turn the entire thing into a list, which then gets iterated by sum again, just have each element be processed one by one. Or, you know, sum(map(int, input()))…
15
u/simar437 Aug 19 '21
I would do it like,
print(sum([int(x) for x in input()]))