#!/usr/bin/python3
# -*- coding: utf-8 -*-
# @Time: 2018/8/15
# @Author: xfLi
def addDigits(num):
"""
:type num: int
:rtype: int
"""
sums = 0
for i in str(num):
sums = sums + int(i)
if sums > 9:
sums = sums - 9
return sums
if __name__ == '__main__':
num = 75
result = addDigits(num)
print(result)
这个我就不明白了:
return num and (num % 9 or 9)