Hi, Preeti,
You have to learn them but if it is any help, most countries which end in -e are feminine so maybe concentrate on the exceptions and on those which are masculine or plural.
Le Maroc, Le Portugal, Le Mexique, Le Cambodge, Le Mozambique, Le Canada, Le Brésil ...
Les Etats-Unis, Les Pays-Bas, Les Philipines...
Hope this helps!