# Odd Even Linked List in Python

Suppose we have a singly linked list, we have to group all odd nodes together followed by the even nodes. Here we are talking about the node position not the value in the nodes. We should try to do it in place. So if the nodes are [1,22,13,14,25], the result will be [1,13,25,22,14]

To solve this, we will follow these steps −

• while next of head2 is nor null and next of (next of head is not null)

• if next of head2 is not null

## Example

Let us see the following implementation to get better understanding −

class Solution(object):
"""
:rtype: ListNode
"""
return head
[1,22,13,14,25]
[1,13,25,22,14]