Generating IDs how to make IDs same length using zeroes?
"always(?)" indeed. Sweden = 46 looks like you mean the telephone not-necessarily-a-country code which is VARIABLE LENGTH ... for example CHINA = 86, HONG KONG (not a country) = 852, CANADA = USA = 1. Is your ID allowed to be variable length or not?
If it is allowed to be variable, you would need do str(countrycode) + str(n).zfill(10) ... this allows n to be up to 10 digits.
Otherwise, for a fixed total length of 12 digits, you would need str(countrycode) + str(n).zfill(12 - len(str(countrycode)))
Update: The requirement is "fixed length 9 digits" so 460 000 000 138 should be 460 000 138
I want to generate IDs on a special form such as 460 000 000 138 where 46 is the country code and the rest is the ID and this number always(?) has the same number of digits ie four pairs of threes.
My input is this ID that can be expected to be lower than some largest number. When starting the project from scratch the ID could be 1 and then just autoincrement as long as IDs don't collide (I probably would want a sequential count but that is tricky in distributed environment where actions can happen at the same time. 
So input could be for example 138. I now want to fill with zeros and the country number, in this case Sweden (46) so the output should be 460 000 000 138
Similarly, if input is 1138 the output should be on the same form an fill with less zeroes ie 460 000 001 138
So I don't know how many zeroes I need. Can you help me? The solution should be in python. I will probably use the entity ID, fill with zeroes and add the country code and can you help me find an algorithm in python for that?
Any help is greatly appreciated