0
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.

1 Answer 1

1

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) 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.