There is no universally agreed number because "city" has no global legal definition. Criteria vary wildly: population thresholds (5,000? 50,000? 100,000?), administrative status, economic function, density, or historical charter.
The United Nations (World Urbanization Prospects) estimated ~33,300 "urban agglomerations" with 300,000+ population in 2018. Of these, 473 exceeded 1 million; 33 were "megacities" (>10M).
For global comparisons, use UN urban agglomeration data (consistent methodology). For national policy, use national statistical office definitions. The "number of cities" is a policy choice, not a fact.