Does increased partisanship undermine the ability of politically heterogeneous groups to function and cooperate in apolitical settings? On the eve of the 2020 U.S. elections, we conducted an online experiment in which Democrats and Republicans played repeated public goods games, both with and without punishment. Absent punishment, mixed-party groups are less cooperative and efficient than homogeneous groups. However, polarized groups fare no worse than those in which political affiliations are unknown. We find no differences in cooperation across groups that are able to punish free-riding behavior. Thus, knowing that one is in a group with like-minded individuals can serve as a substitute for an enforcement mechanism, but polarized groups can, at some efficiency cost, achieve similar contributions when sanctions are possible.