names.txtИван
Степан
father_names.txtИванович
Степанович
combine.py#!/usr/bin/env python
# -*- coding: utf-8 -*-
names_file = 'names.txt'
father_names_file = 'father_names.txt'
combinations_file = 'combinations.txt'
def main():
with open(combinations_file, 'w') as combinations:
with open(names_file, 'r') as names, open(father_names_file, 'r') as father_names:
names_lines = names.readlines()
father_names_lines = father_names.readlines()
for name in names_lines:
for father_name in father_names_lines:
line = "%s %s" % (name.replace("\n", ""),
father_name.replace("\n", ""))
combinations.write("%s\n" % line)
if __name__ == '__main__':
main()
combinations.txtИван Иванович
Иван Степанович
Степан Иванович
Степан Степанович