Program go through the list and print number which digits have the highest sum. I have an idea of getting digits of numbers and saving it to a list and doing the same for the next number but in other list.Then compare these two lists and print the number with the highest list.
I tried something but it don't work how I wanted it.
brojevi = [21, 35, -43, 2, 80, -1, 7, 0]
tmax = []
tmax2 = []
for i in brojevi:
broj1 = i
broj2 = i +1
while broj1 > 0:
cifra1 = broj1 % 10
tmax.append(cifra1)
broj1 //= 10
print(cifra1)
print(broj1)
print("-----------------")
while broj2 > 0:
cifra2 = broj2 % 10
tmax2.append(cifra2)
broj2 //= 10
print(cifra2)
print(broj2)
print("-----------------")
zbir1 = sum(tmax)
print("-----------------")
zbir2 = sum(tmax2)
print(zbir1)
print(zbir2)
if zbir1 > zbir2:
print("najveci: ", i)
print(tmax)
print(tmax2)
Prints in code are for test purposes.