i have 20000 pic in my iphone x and my battery life now is 76 !!!!! Does the number of pictures affect the battery life?
No!
To get an understanding of how Battery Levels & performance are related see this: iPhone Battery and Performance - Apple Support
i have my phone for just 2 years and i know how to save the battery
There will be wear and tear, which is gradual and normal for all Li-ion batteries. It is not only the duration (02 years) that matters but also how/how often the device has been used within that duration (02 years) that matters. If your battery still supports Peak performance of your iPhone, continue to use your phone as you normally would. Otherwise see an Apple-authorized Service Center or Apple Support for further assistance.