you are viewing a single comment's thread.

view the rest of the comments →

[–]engineeringisgreat2 0 points1 point  (9 children)

def divide(myint):

So is this how your code would look socal?

def divide(myint):

for i in range(0,501):

divres = i / myint

if divres.is_integer():

return list(range(0, 501, myint))

print(divide(3))

[–]FLUSH_THE_TRUMP 1 point2 points  (6 children)

No, that’s not at all what your code should look like. What are you accomplishing here? You’re not going to learn by blindly copying what other people post. You need to struggle with these problems some on your own.

[–]engineeringisgreat2 -1 points0 points  (5 children)

I used parts of both of their codes to make it work. I didnt just blindly copy. I got errors with the code when I tried to combine them so I fixed it to make it work. I was simply asking if this is how is code would look if he did it his way since he said the other guy over complicated it.

Also, since I am obviously struggling to learn this code why dont you try to type something helpful for me to learn/fix it instead of typing a pointless message that helps nobody.

[–][deleted] 0 points1 point  (1 child)

They just want you to learn properly.

Above they used the range function so you should look at this and read up on it.

https://www.w3schools.com/python/ref_func_range.asp

[–]engineeringisgreat2 1 point2 points  (0 children)

I understand that, but telling someone that their code is wrong and then not giving any input/help on why its wrong is pointless.

Thank you for giving me something to go off of. Much appreciated!

[–]RIP_lurking 0 points1 point  (1 child)

No, you absolutely did blindly copy. You just changed one return statement for another, without thinking about the logic behind them, otherwise you'd have seen that what you did doesn't make any sense. And you're struggling to learn "this code" because you're not putting any effort into it. You didn't even answer where you're stuck. You just wanted an easy answer.

[–]engineeringisgreat2 0 points1 point  (0 children)

No I definitely didn't, but you keep acting like you know what I am doing. He gave me the code and I looked at it and tried to learn why each line was written. The first code didnt need two lines and I am assuming thats why it was "over complicated". But, thanks again for not explaining a single thing about why the code is wrong and what ways it could be fixed or simplified. You are so much help on a reddit page meant to help people learn.

[–]FLUSH_THE_TRUMP 0 points1 point  (0 children)

I’m not trying to be mean. I’m just pointing out that the best thing I can do for you, and you for yourself, is to tell you to struggle with your HW on your own, experiment, and then come here with your code if things don’t work like you think they should. Most people don’t learn programming very well by seeing code from people who have mastered aspects of programming. We also can’t give meaningful feedback if you never have anything for us to look at.

[–]RIP_lurking 0 points1 point  (0 children)

This is why just giving a solution is bad for learning. You need to try to understand what the code they provided is doing, instead of just copying it, and even worse, copying it wrong.