Jump to content
  • Create New...

Python Little Convertion Function

Recommended Posts

Hi metin2dev today i wanna release a little function to convert in the easyest way number in pointed number string.




From :150000000


In : 150.000.000




It's very usefull if you need to create a  new coins manage interface like that:




Here the full commented code:

def splittedvalue(value):
	x = value
	x_list = list(x) #convert string in list
	x_list.reverse() #reverse list for the right point 

	if len(x)%3 == 0:   #checking how many point must insert.If there is not rest,  point -1 to avoid .100.500
	   count_point = len(x)/3-1
		count_point = len(x)/3 
	for point in range(0,count_point):  #insert the points in the right place

	x_list.reverse()  #reverse again the list as begining
	x_list = "".join(x_list) #reconvert list in string
	return x_list  #finally return string value with point

Reguards Luzzo

  • Love 1
Link to comment

There is already a default function in the locale.py/localeInfo.py it's called NumberToMoneyString()


In the default function you have a limit on the index.


This function anyway is more friendly and easier to use..

Link to comment

Which limit do you mean? And how is there any difference in usage?


a ) NumberToMoneyString(1234567)

b ) splittedvalue(1234567)


Moreover, due to the operations your function perform, it's most likely slower. And it only accepts strings, not ints or floats (can be quickly ammended though).

Link to comment
  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.