TypeError : l'objet 'int' n'est pas itérable

Solved
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:

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

yg_be Posted messages 23437 Registration date   Status Contributor Last intervention   Ambassadeur 1 588
 
Hello,
we will be able to advise you more easily if you explain what you are trying to achieve by writing
int(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?
1
Lulupoulet Posted messages 9 Status Member
 
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.
0
yg_be Posted messages 23437 Registration date   Status Contributor Last intervention   1 588 > Lulupoulet Posted messages 9 Status Member
 
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.
0
Lulupoulet Posted messages 9 Status Member
 
You're welcome anyway for your help.
0