이론 공부

//= (ex) x //= r)

옥식 2021. 12. 27. 00:07

참고

https://stackoverflow.com/questions/13677306/exercise-on-summing-digits-whats-with-n-10

 

Exercise on Summing Digits | What's with n // = 10

Possible Duplicate: What is the reason for having ‘//’ in Python? While trying to do an exercise on summing digits, I stumbled on this solution: def sum_digits(n): import math total = 0...

stackoverflow.com

//= 이것도 +=이 작동하는 원리와 같다

 

예를 들어 

x += 1 은 x = x + 1 인 것처럼

x //= r 은 x = x // r 인 것이다.

 

참고로 //은 나머지는 버리고 몫만 나타내는 연산자다.

예시

6//4 = 1