TypeError : l'objet 'int' n'est pas itérable
Solved
Lulupoulet
Posted messages
9
Status
Member
-
Lulupoulet Posted messages 9 Status Member -
Lulupoulet Posted messages 9 Status Member -
Bonjour,
I have the error "TypeError: 'int' object is not iterable" when I run my Python program which is:
And the error message is:
Since my level in Python is close to zero, I can't solve this problem. That's why I'm asking if you would mind helping me even if the error is obvious to you.
Thank you in advance.
I have the error "TypeError: 'int' object is not iterable" when I run my Python program which is:
import random k = random.randint(1, 82) for i in range(1,82): if i * k < 82 : i * k < 82 == n k == random.randrange(min(n), max(n)) print(k) elif i % k == 0 : i % k == b k = random.randrange(min(b),max(b)) print(k) else: break
And the error message is:
line 6, in <module> k == random.randrange(min(n), max(n)) TypeError: 'int' object is not iterable
Since my level in Python is close to zero, I can't solve this problem. That's why I'm asking if you would mind helping me even if the error is obvious to you.
Thank you in advance.
1 answer
-
Hello,
we will be able to advise you more easily if you explain what you are trying to achieve by writingint(n)
.
I notice that line 6 you shared is different from the one in the error message. Strange, isn't it?
Can you make sure to use the code tags when you share code?
The syntax of your line 5 (and other lines) seems strange to me: what are you trying to do with it?-
Ok, I changed my message, the error message was not the same because I accidentally took an old one. In line 5 I want to multiply the random number at the beginning by all the numbers between 1 and 81, then only keep those below 81. If you see other lines that are hard to understand, it's normal, I'm just starting out.
- I suggest that you first write simpler programs, give more descriptive names to your variables, and add comments to describe what you expect from each instruction.
I also suggest that you add print statements to understand the behavior of your program.
What documentation do you use to write in Python? I feel like you are inventing a new programming language.
-
-