Posts with the [Quick Coding Tip] tag are thought for giving a quick solution to simple PyQGIS tasks.
If you already know How to load a layer in QGIS using Python, you may run the following code:
feats_count = layer.featureCount()
for getting the total number of features that are stored in the current vector layer.
Instead, if you want to obtain the count of the selected features only (see here for learning how to perform this task), you may run the following code:
feats_count = layer.selectedFeatureCount()
Regardless of the method used, the total number of features will be stored in the feats_count variable, which could be easily returned by a simple