Cannot Figure Out How to Format This


I am attempting to call and define a function within a for loop in Python. I have looked through the internet and have not found a way to solve this. I decided to give it a shot and was not successful.

Here is my code:

product = 1
def numbers(nums):
return nums
for number in numbers:
product = product * numbers

Here is the error:

TypeError: 'function' object is not iterable on line 4

Could someone please point out my error and how to fix my code?

Replace this line with your code.


Hi, @codicorn ,

There are several problems in your code. However, for us to fully understand and discuss them, we need to see how the code you submitted to the Python interpreter is indented.

When you post code, it is important for you to format it so that we can discern that indentation, along with other details. Please see How do I format code in my posts?, and then present your code in a formatted manner, so we can better help with it.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.