The coevolution of networks and political attitudes