Your first code sample picks up 3 digits at a time of the number and joins them. Breaking it up
>>>num = '1234567'
>>>x=[num[i:i+3] for i in range(0, len(num), 3)]
>>>x
['123', '456', '7']
>>>'.'.join(x)
'123.456.7'
The num[i:i+3]
part is called slicing and explained here.
While in the second part you use the join function to connect the parts again.
>>>num = '2333'
>>>num[0:2]
23
>>>'.'.join('23')
2.3
What you want is 1.234.567
, i.e. you want to start counting three digits from the end of the string. One way would be to reverse the string, do what you are doing and reverse the result.
>>> num = '1234567'
>>> num[::-1]
'7654321'
>>> '.'.join(num[::-1][i:i+3] for i in range(0, len(num), 3))[::-1]
'1.234.567'