convert x into a string for every x in list of version elements up to the parts index, join the previous into a string separated by '.', assign the result to major.
major = '.' . join ( str ( x ) for x in version [ : parts ] )