For that you have to use the Aufbau principle
For example, writing the electronic configuration of Fe(28)
I recommend that you memorize the aufbau principle. Once you learn it, you don’t need anything else except the atomic number of the element to write it’s electronic configuration.