This paper proposes an adaptive penalty function for solving constrained optimization problems using genetic algorithms. The proposed method aims to exploit infeasible individuals with low objective value and low constraint violation. The number of feasible individuals in the population is used to guide the search process either toward finding more feasible individuals or searching for the optimum solution. The proposed method is simple to implement and does not need any parameter tuning. The performance of the algorithm is tested on 22 benchmark functions in the literature. The results show that the proposed approach is able to find very good solutions comparable to the chosen state-of-the-art designs. Furthermore, it is able to find feasible solutions in every run for all of the benchmark functions tested.