user1798666
user1798666

Reputation: 9

Matrix kind-of program

I get TypeError: 'int' object is not iterable on the following code, why?

def temp_media(c, l):
    c_ini = c
    l_ini = l
    res_vert = 0
    res_horiz = 0
    dim = dimensoes()
    c_max = dim[0] // 2
    l_max = dim[1]
    for l in l_max:
        for c in c_max:
            res_vert = res_vert + calcula_temp(c, l)
        res_horiz = res_horiz + calcula_temp(c, l)
    return (((res_horiz / (c_max - c_ini)) + (res_vert / (l_max - l_ini))) / 2)

How can I fix this?

Upvotes: 0

Views: 60

Answers (1)

Eric
Eric

Reputation: 97555

You need to use range (or xrange in python 2) in your for loops:

c_max = dim[0] // 2
l_max = dim[1]
for l in range(l_max):
    for c in range(c_max):

Upvotes: 2

Related Questions