<｜begin▁of▁sentence｜>### Instruction:
Given a graph with edge set [(1, 1), (1, 2)], how do you list all the nodes with self-loops using NetworkX?
### Response:
import networkx as nx

# Create a graph
G = nx.Graph()

# Add edges including a self loop
G.add_edge(1, 1)
G.add_edge(1, 2)

# Get a list of nodes with self loops
self_loop_nodes = list(nx.nodes_with_selfloops(G))

print(self_loop_nodes)
<|EOT|>
