title: Why my function is not called in every single iteration?
body: <p><strong>Code:</strong></p>
  <p>why function <strong>save_path()</strong> is called only for once?</p>
  <pre><code>from random import choice
  from os.path import exists
  from os import mkdir
  
  number_of_chars = int(input('enter the number of letters in each file: '))
  data = input('enter the sequence of letters: ')
  number_of_files = int(input('enter the number of files: '))
  
  def save_path(folder_name = input('enter name of folder in Desktop(press ENTER for saving in Desktop itself): ')):
      # if the folder does not exist on the Desktop, this function creates it
      tmp_path = 'C:/Users/MyComputerName/Desktop/%s' % folder_name
      if not exists(tmp_path):
          mkdir(tmp_path)
      return tmp_path
  
  for j in range(1, number_of_files + 1):
      # each time a file is created in the given path
      with open('%s/test%i.txt' % (save_path(), j), 'w') as f:
          current_choice, last_choice = '', ''
          for i in range(1, number_of_chars + 1):
              # consecutive characters cannot be the same
              while current_choice == last_choice:
                  current_choice = choice(data)
              last_choice = current_choice
              if i != number_of_chars:
                  f.write(current_choice + ' ')
              # if this is the last character, then no need for a space character
              else:
                  f.write(current_choice)
          print('%2i done!' % j)
          f.close()
  </code></pre>
  <p><strong>Output:</strong></p>
  <blockquote>
  <p>enter the number of letters in each file: 20</p>
  </blockquote>
  <blockquote>
  <p>enter the sequence of letters: gh</p>
  </blockquote>
  <blockquote>
  <p>enter the number of files: 5</p>
  </blockquote>
  <blockquote>
  <p>enter name of folder in Desktop(press ENTER for saving in Desktop itself):</p>
  </blockquote>
  <blockquote>
  <p>1 done!</p>
  </blockquote>
  <blockquote>
  <p>2 done!</p>
  </blockquote>
  <blockquote>
  <p>3 done!</p>
  </blockquote>
  <blockquote>
  <p>4 done!</p>
  </blockquote>
  <blockquote>
  <p>5 done!</p>
  </blockquote>
  <p><strong>Result:</strong> <a href="https://i.stack.imgur.com/KXgGh.png" rel="nofollow noreferrer">screenshot</a></p>