You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
def toalpha(a):
result = []
if len(a) == 1:
result.append(unit.get(a))
if len(a) == 2:
if a[0] == "1":
result.append(tens.get(a[0::]))
else:
result.append(tens.get(a[0]))
result.append(unit.get(a[1]))
if len(a) == 3:
result.append(hundreds.get(a[0]))
if a[1] == "1":
result.append(tens.get(a[1::]))
else:
result.append(tens.get(a[1]))
result.append(unit.get(a[2]))
for a in range(len(result)-1):
if result[a] == "":
result.pop(a)
return " و ".join(result)
def count(b):
res = []
for i in range(ceil(len(b) / 3)):
if len(b)% 3 > 0:
res.append(toalpha(b[0:len(b)% 3:]))
b = b[len(b)% 3:]
else :
res.append(toalpha(b[0:3:]))
b = b[3:]
return res
def main(ta):
total = str(int(ta))
result = count(total)
resultreversed = result[::-1]
final = []
p = ""
for i in range(len(resultreversed)):
final.append(resultreversed[i] + " " + prefix[i])
for i in reversed(final):
p += i
return p
The text was updated successfully, but these errors were encountered:
mrr-r
changed the title
Please add Pesian language
Please add Persian language
Apr 11, 2021
Hello,
Thank you for your module.
Please add to your module Persian language, you can use our symbol with follow code:
unit = {
"0" : "" ,
"1" : "یک" ,
"2" : "دو" ,
"3" : "سه" ,
"4" : "چهار" ,
"5" : "پنج" ,
"6" : "شش" ,
"7" : "هفت" ,
"8" : "هشت" ,
"9" : "نه"}
tens = {
"0" : "" ,
"10" : "ده" ,
"11" : "یازده" ,
"12" : "دوازده" ,
"13" : "سیزده" ,
"14" : "چهارده" ,
"15" : "پانزده" ,
"16" : "شانزده" ,
"17" : "هفده" ,
"18" : "هجده" ,
"19" : "نوزده" ,
"2" : "بیست" ,
"3" : "سی" ,
"4" : "چهل" ,
"5" : "پنجاه" ,
"6" : "شصت" ,
"7" : "هفتاد" ,
"8" : "هشتاد" ,
"9" : "نود"}
hundreds = {
"0" : "" ,
"1" : "یکصد" ,
"2" : "دویست" ,
"3" : "سیصد" ,
"4" : "چهارصد" ,
"5" : "پانصد" ,
"6" : "ششصد" ,
"7" : "هفتصد" ,
"8" : "هشتصد" ,
"9" : "نهصد"
}
prefix =[
"ریال" ,
"هزار و" ,
"میلیون و" ,
"میلیارد و" ,
]
def toalpha(a):
result = []
if len(a) == 1:
result.append(unit.get(a))
if len(a) == 2:
if a[0] == "1":
result.append(tens.get(a[0::]))
else:
result.append(tens.get(a[0]))
result.append(unit.get(a[1]))
if len(a) == 3:
result.append(hundreds.get(a[0]))
if a[1] == "1":
result.append(tens.get(a[1::]))
else:
result.append(tens.get(a[1]))
result.append(unit.get(a[2]))
for a in range(len(result)-1):
if result[a] == "":
result.pop(a)
return " و ".join(result)
def count(b):
res = []
for i in range(ceil(len(b) / 3)):
if len(b)% 3 > 0:
res.append(toalpha(b[0:len(b)% 3:]))
b = b[len(b)% 3:]
else :
res.append(toalpha(b[0:3:]))
b = b[3:]
return res
def main(ta):
total = str(int(ta))
result = count(total)
resultreversed = result[::-1]
final = []
p = ""
for i in range(len(resultreversed)):
final.append(resultreversed[i] + " " + prefix[i])
for i in reversed(final):
p += i
return p
The text was updated successfully, but these errors were encountered: