#Guys lil help plz!
70 messages · Page 1 of 1 (latest)
a & b doesn't do what you think it does
so how would i do it then? yea output theres an error there its supposed to be print(a2 & b2)
unless you think it does bitwise AND operation, but then I'm not sure that's useful in this program
i just need the output to print similar numbers from a & b divisors
How are you learning python?
uhh i dont know what u mean srry, in school i guess
do you have tutorials or reference materials from school? or are you just writing what you think the code should look like?
I'm only asking because it seems like the resources you're using may be misleading or outdated
I'm just doing it from previous methods, I know there's a more optional way but I'm bad
And I missed class for this part but i have to do it at home
were you ever introduced to the & operator? it's very uncommon to use in python
Yea I used it some times
to do what?
For conditions
Multiple conditions
& is not a conditional operator, it takes two numbers and returns a third
Are you thinking that & and and are the same?
Yea
Because as christopher said, in python they're different
but also, print(a and b) would probably not display what I think you want here
Yea error there
ohh ok i got it now
wait nvm
its not giving me the right common divisors
after changing & to and
At the moment your code has too many issues that fixing one still leaves a lot
Could you give us your overall goal for this code?
Each thing it's supposed to achieve
- Find all the divisors of a
- Find all the divisors of b
- Find all the common divisors between a and b
- Find the highest values from the common divisors between a and b
a and b is input
i got 1-2 good tho juast 3 & 4 left
Okay steps 1 and 2 are fine
but wouldn't it be smarted to somehow store what you find in 1 and 2
so that you can use them in 3 and 4?
you'd want two lists, one for the divisors of a, another for the divisors of b
No, this doesn't work
Think about all the ways you know how to store values
Have you heard of lists? tuples? sets? dictionaries? etc?
lists and sets i think
i just cant remember how you do it, i usually have to refer to stuff ive done
Maybe it's time to learn then 😊
ohh i got it
u use thiss [a,b]
ok i got it
idk let me know if theres a better way to do this ig...
had a 2month break, coding just slips out easily
Did you test the code?
wait rlly?
Yes
6 is not a common divisor of 3 and 6

c[a==b] gives boolean result instead...
omg finally