# my accept python solution

• ``````class Solution(object):
def numberToWords(self, num):
"""
:type num: int
:rtype: str
"""
if not num:
return 'Zero'
dicx={0:'',1:' One',2:' Two',3:' Three',4:' Four',5:' Five',6:' Six',7:' Seven',8:' Eight',9:' Nine'}
dic1x={10:' Ten',11:' Eleven',12:' Twelve',13:' Thirteen', 14:' Fourteen', 15:' Fifteen',16:' Sixteen', 17:' Seventeen',18:' Eighteen',19:' Nineteen'}
dicx0={0:'',2:' Twenty', 3:' Thirty', 4:' Forty', 5:' Fifty', 6:' Sixty', 7:' Seventy', 8:' Eighty', 9:' Ninety' }
dicunit={0:'',1:' Thousand',2:' Million',3:' Billion'}
unit=0
res=''
while num:
this=num%1000
here=((dicx[this/100]+' Hundred'if this/100!=0 else '')+dic1x[this%100]) if this%100 in dic1x else ((dicx[this/100]+' Hundred'if this/100!=0 else '')+ dicx0[(this/10)%10]+dicx[this%10])
if here:
res=here+dicunit[unit]+res
unit+=1
num/=1000
return res[1:]
``````

if there is any advice for me, just tell me, i'd upvote you.

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.