# Python Program to Swap Adjacent Nodes in a Circular Linked List

This Python program swaps adjacent nodes in a circular linked list. A circular linked list is a linked list where the last node points back to the first node. Swapping adjacent nodes means exchanging the positions of two consecutive nodes in the list.

Swapping adjacent nodes in a circular linked list involves exchanging the positions of nodes that are next to each other within the list. A circular linked list is a data structure in which each node points to the next node, and the last node connects back to the first node, forming a closed loop. Swapping adjacent nodes can be a useful operation when reordering elements or modifying the arrangement of data within the circular linked list.

## Problem Statement

You are given a circular linked list, where each node contains an integer value. Implement a function that swaps the data of adjacent nodes throughout the circular linked list.

## Python Program to Swap Adjacent Nodes in a Circular Linked List

```class Node:
def __init__(self, data):
self.data = data
self.next = None

def __init__(self):

def append(self, data):
new_node = Node(data)
else:
temp = temp.next
temp.next = new_node

def display(self):
return
while True:
print(temp.data, end=" ")
temp = temp.next
break
print()

return

current.data, current.next.data = current.next.data, current.data
current = current.next.next

# Example usage
cll.append(1)
cll.append(2)
cll.append(3)
cll.append(4)

cll.display()

cll.display()
```

## How it Works

1. Initial Circular Linked List:markdownCopy code`1 -> 2 -> 3 -> 4 ^ | |_________________|`
2. Identify and Swap Adjacent Nodes:
• Start at the first node (1).
• Swap the data of the current node (1) with the data of the next node (2).
• Move to the next node (2).
• Swap the data of the current node (2) with the data of the next node (3).
• Move to the next node (3).
• Swap the data of the current node (3) with the data of the next node (4).
• Move to the last node (4).
• Swap the data of the current node (4) with the data of the next node (1).
• The entire circular linked list has been traversed, and adjacent nodes have been swapped.