Potassium (K) is a metal having 1 valence electron, and fluorine (F) is a nonmetal having 7 valence electrons. Recall that having 8 valence electron (electrons in the last shell of an atom) is a stable atom. Since both potassium and fluorine need to lose and gain, respectively, a valence electron to become stable, an ionic bond form between them where the electron lost by potassium goes to fluorine.