Jan-16-2022, 01:52 PM
(Jan-16-2022, 11:33 AM)ibreeden Wrote: Hi @Frankduc ,
I am glad you got your program running. But if you don't mind I have two warnings.
First: you named a variablelist
. But this name is a built-in! Do not use build-ins as a name of a variable because it will hide this built-in! This practice can cause errors that are difficult to understand!
Second: for making the program clear and understandable: choose the names of your variables carefully. See how Deanhystad chose the names "primes" and "not_primes". It makes very clear what they are used for and will help you when you have to maintain the program. In your version you will later have a hard time to understand what the function does when the function returns "list" instead of "prime_list".
I did not know about list obviously, i will keep that in mine. I think also it is clear i have started this code by copying others not working code and try fitting parts of it to make something new. I did not bother using new names. I should be more carefull about that. I am wasting to much time searching answers in others code on the net when i should just trusting myself and be more consistant.
I thought in the first def function by returning prime_eratosthenes(lim) at the end of function it was automatically sending the prime numbers to the other def printPairs(lim): by doing primes = prime_eratosthenes(lim). Strange!
Thank you to both of you.
Now i will try to list all combinations possible as an exercise.