#!/usr/bin/python

letters = [
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'
]
length = 4
list = letters
tmp_list = []

def add_letter(list):
  result = []
  for text in list:
    for letter in letters:
      result.append(text+letter)
  return result

for i in range(length - 1):
  list = add_letter(list);

with open("slownik.txt", "wb") as f:
  for element in list:
    f.write(element+" ")
