The ending doesn’t always tell
Most nouns in ‑o are masculine and most in ‑a feminine. Then come il problema, la mano, and every noun in ‑e: il fiore, la notte.
Every noun is saved with its article and gender. Where the ending doesn’t tell, it gets a card that asks masculine or feminine?