For MAPbI3-based cells, the highest efficiency of 27.10% was achieved at an electron affinity of 3.75 eV. Similarly, MASnI3-based cells exhibited a maximum efficiency of 27.98% at an electron affinity of 4.00 eV. These optimized values highlight the critical role of electron affinity in achieving maximum device performance, corroborating previous studies emphasizing its importance in perovskite solar cells