Women, and particularly women in all-female groups, appear to be especially adept at providing public goods in developing countries. We use a one-shot Public Goods game to explore the effect of sex and a group's sex composition on the voluntary provision of public goods in a Nairobi slum. Sex heterogeneity hurts the voluntary provision of public goods because women—but not men—contribute less in mixed-sex than same-sex groups. Women contribute as much as men in same-sex groups. This result is driven by women's pessimism and men's optimism about others’ contributions in mixed-sex groups rather than by gendered social preferences.