Explanation plz


#1



def digit_sum(n):
    sum = 0
    while n > 0:
        sum += n % 10
        n //= 10
    return sum
print digit_sum(52)

what does n //= 10 mean?


#2

for the fact that you wrote this solutions, it is kind of worrying you don't know what it is doing.

n //= 10 is a shorthand for n = n // 10, which simply means divide n by 10 and floor the number if needed. i don't understand why // is used, in python2 / will also floor the number if you divide two integers.


#3

In Python 3, the / operator returns a floating point value even when both operands are integers, whereas the // operator is used for integer division.
// was introduced for forward-compatibility in Python 2.2, enabling you to write Python 3-compatible code in Python 2.


#4

i know, you don't have to tell me? Or was it not on purpose to reply to me?


#5

You wrote:

i don't understand why // is used, in python2 / will also floor the number if you divide two integers.

I replied why it's a good habit to explicitly use // to floor it even when programming in Python 2, so that others can learn, and also chose to reply to you specifically in case you weren't aware (and hence might appreciate the information).
You can probably see why one might assume that you're out of the loop after having read that last sentence of yours.


#6

Dude, get of your shielded fluffy horse. She was replying to you. But you get too defensive, like if a user had critiqued your smile


#7

stetim94. Set the example, to be able to take constructive criticism, if youre going to be a mod.


#8

Dude, please, don't.


But you get too defensive, like if a user had critiqued your smile

He simply asked if her message was properly addressed. What's defensive in that?

Set the example, to be able to take constructive criticism

Now I need an explanation. Where do you see a criticism in @aylamarianna post? She simply added her own insight.


I seriously doubt that anyone got offended. Do not create unnecessary tension. Respect moderators and other users. If you want to impress someone this is not the right place.


#9

Not here to impress anyone, nor to assume someone's attempting to impress.

It's impossible not to notice his condescending note in his reply


#10

i later viewed my rubbish answer, the reply was indeed for good reason addressed for me. The problem is that my answer is rubbish.

The problem is that it can be difficult to always write high quality answers. I know the points aylamarianna was trying to tell me, that confused me for a bit, until i reviewed my answer (which i should have done first)

aylamarianna was right to correct me, sorry if i took a defensive stand in this, it was never my intention. Moderators are still human, and make mistakes. It seems i made one here, you made a valid point @mindrick


#11

@factoradic :wink: Now can you see

**

**


#12

I don't know why you wish to continue this discussion.

@factoradic :wink: Now can you see

No, not really. I still do not see what is wrong with stetim94 message. I understand why he apologized, but I still do not see anything wrong or offensive in his post. And I don't see any critique that you mentioned before in the aylamarianna post.

Yes, I still think that your post is completely redundant and it was intended only to create unnecessary tension.


If you still want to prove that your post was meaningful and I was wrong please do not use as an argument the fact that someone is nice. Show me, exactly, without any conjectures where was the critique and how your post improved this discussion. Please do this via PM, user problem is solved, topic closed.


#13