• Register
1 vote


What’s wrong with my codes? Can anybody please pull me up?

# add_list([1, 2, 3]) should return 6
# summarize([1, 2, 3]) should return "The sum of [1, 2, 3] is 6."
# Note: both functions will only take *one* argument each.

added_list = list()
sum = 0

def add_list(num):

def sum(num):
  sum = sum + add_list[num]

for num in 4:


Thanks in advance.




12 7 7
15,250 points

1 Answer

1 vote


The problem created on that line when you wrote  for num in 4 : 

The ‘for’ operator works only for iterable data like list, string or other object containers. To avoid this error you may use a useful function called range function.
So, use

for num in range(4) :

instead of

for num in 4 :

Good day!

13 9 6
94,240 points

Related questions

1 vote
1 answer 31 views
Problem: Hello kodlogs, I am new to python I am trying to implement the basic program but dont know I am getting an error basically I am new to python language below is the code, this is all new to me as a belong to c language background so this is getting me ... line 1, in <module> TypeError: 'int' object is not iterable I don&rsquo;t know what I am doing wrong can someone please help this.
asked Jun 22 Gavin 15.3k points
1 vote
1 answer 55 views
Problem: I am doing a course on python programming language. As a begginer I have to do a lot of programming practice and some of them are very confusing. Today I wrote a code to do some counting problems in python. The code I wrote is: def count(serial, totals): ... is not iterable What is the problem in my programm and what should I do now. Can anyone explain me this error. Thanks in advance.
asked Apr 4 LizzyM 6.1k points
2 votes
2 answers 441 views
Problem: Hello Kodlogs, I am a new student of Python programming. I am learning the language from YouTube and other voluntary websites and solving basic level problems from them. I&rsquo;ve written a piece of python program that is not working properly and throws back an error ... please point out the issue and help me to fix it? I appreciate your effort and valuable time very much. Thanks a ton.
asked Apr 26 Gavin 15.3k points
2 votes
1 answer 92 views
Problem: Hello Kodlogs, I am a new fellow in this forum. I joined the forum because of you people. I think you guys are awesome and pretty much helpful to each other. Well, let me come to the point now. I have a python list in my program. I want to iterate ... (data): for item in data: print(item) I am looking forward to hearing from you. Thanks for your valuable time and kind concern. Thanks.
asked Apr 25 Gavin 15.3k points
1 vote
1 answer 999 views
Problem: Hello guys, I have a chunk of python code where I am trying to extract all the links from a particular website. For that, I am using selenium.webdriver. But the program is not retrieving the links from that website as I am expecting. Instead of that, it is ... problem? I really appreciate your help in this regard. It took already much times from me but couldn't find any way. Thanks a lot.
asked Apr 21 Gavin 15.3k points