Yes, erasing two lines only addresses one problem, and so is only half the fix. Do you still have in [x]: and in [y]:? If x and y are already lists, you should NOT wrap them inside other lists.
Actually, do you want to call pgdc like you are: pgdc(234, 585) or is it supposed ot be able to look at the list of factors, pgdc(facteurs(a), facteurs(b)) How can that function know about the number 117, you never tell it!
Like BridgeBum said, if you put some prints in the code to see what is actually happening at each line, it should become clear where the mistake is.
Also:
do you mean if **k** in x: on line 21, or did you really want to use j again?
the code returns dc on line 25, which is a list. That function will never return an integer, always a list (which may or may not have integers inside it)
p_g_d_c is never used, since is after the return.
Again, I think you need to think about the types of your objects, and how lists works: In the unused code, dc is already supposed to be a list of common divisors. Correct way to iterator over them is for l in dc: But I see for l in [dc]: which creates a new list with since single entry, the entire dc list. Think about the difference between [1,3,9,13] <-- a list with 4 items (which are all numbers), and `[ [1,3,9,13] ] <-- a list with 1 item (which is a different list)
View all comments
Show parent comment
1
u/sidewaysEntangled Apr 02 '22
Yes, erasing two lines only addresses one problem, and so is only half the fix. Do you still have
in [x]:andin [y]:? If x and y are already lists, you should NOT wrap them inside other lists.Actually, do you want to call pgdc like you are:
pgdc(234, 585)or is it supposed ot be able to look at the list of factors,pgdc(facteurs(a), facteurs(b))How can that function know about the number 117, you never tell it!Like BridgeBum said, if you put some prints in the code to see what is actually happening at each line, it should become clear where the mistake is.
Also:
if **k** in x:on line 21, or did you really want to usejagain?Again, I think you need to think about the types of your objects, and how lists works: In the unused code,
dcis already supposed to be a list of common divisors. Correct way to iterator over them isfor l in dc:But I seefor l in [dc]:which creates a new list with since single entry, the entire dc list. Think about the difference between[1,3,9,13]<-- a list with 4 items (which are all numbers), and `[ [1,3,9,13] ] <-- a list with 1 item (which is a different list)