repeat1=0 while repeat1!=x1: fini=ord(dlist[repeat1]) repeat1=repeat1+1 print (fini) sum_of_all=sum(fini) print(sum_of_all) i want to add the numbers that are made from the variable fini. python gives me an error saying: 'int' is not iterable.
You need to build a list of those numbers. You are instead just assigning each number to fini without doing anything with the preceding numbers:
values = [] while repeat1 != x1: fini = ord(dlist[repeat1]) values.append(fini) repeat1 = repeat1 + 1 sum_of_all = sum(values) You may as well just sum the values in the loop however:
sum_of_all = 0 while repeat1 != x1: fini = ord(dlist[repeat1]) sum_of_all += fini repeat1 = repeat1 + 1 print(sum_of_all)