title: Why is the function inside the dictionary executing before they're called
body: <p>I'm trying to make simple code that reads names and put it on a list, what i am intending to do is a series of functions to add names to the list, remove name, find name position etc. so it will have a lot of <em>ifs</em>, to avoid that i tried to use a dictionary to store the functions that will be called, but when i execute the program the functions inside the dictionary are running before i can input the number to execute it</p>
  <pre><code>def addName(nameListAux):
      &quot;&quot;&quot;Returns a list of names
  
      Args:
          aux str: name that will add to the list list
      &quot;&quot;&quot;
  
      name = str(input('Enter a new name: '))
  
      while name != 'quit':
  
          nameListAux.append(name)
          print(nameListAux)
          name = str(input('Enter a new name: '))
  
      print(nameListAux)
      return nameListAux
  
  
  def searchName(searchedNameList):
      &quot;&quot;&quot;Search a name on the list
  
      Args:
          searchedNameList list: list that will search the name
  
      Returns:
          int: position of the name in the list
      &quot;&quot;&quot;
      name = str(input('Enter name to be searched: '))
  
      listLength = (int(len(searchedNameList)) // 2) - 1
  
      while listLength &lt;= (int(len(searchedNameList) - 1)):
          if name == searchedNameList[listLength]:
              return print('the name is at position', listLength)
          listLength += 1
  
      listLength = (int(len(searchedNameList)) // 2) - 1
  
      while listLength &gt;= 0:
          if name == searchedNameList[listLength]:
              return print('the name is at position', listLength)
          listLength -= 1
  
  
  if __name__ == '__main__':
  
      nameList = []
  
      selectionDict = {
          1: addName(nameList),
          2: searchName(nameList),
      }
  
      while True:
          switch = int(input('''Choose a option:
          1- Add name to list
          2- Search for name in list
          '''))
  </code></pre>