**How to Separate Odd and Even Numbers in Python**

When you perform division operation on any number by 2 then it may give ‘0’ or ‘1’ if remainder is ‘0’ then that is an even number. if reminder ‘1’ then that is an odd number.

### Example:

2%2 = 0 #Remainder is ‘0’ so it is **even number**

3%2 = 1 #Remainder is ‘1’ so it is **odd number**

**Write an algorithm for Odd and Even Number in Python**

step1: Start

step2: def variable(ABC):

step3: Take an empty set of odd and even

step4: Use loop in the number you given

step5: Check the condition if it’s true then append in even else odd

step6: Return output

step7: Enter the number

step8: print(def_variableName(pass_number))

step9: end

### Example:

In this example we will see, how can we separate odd and even number using the **append()** method.

def odd_even(num):

odd=[]

even=[]

for i in num:

if i%2 == 0:

even.append(i)

else:

odd.append(i)

output_num=[odd,even]

return output_num

number=[1,2,3,12,15,6,7,8,9]

print('Odd and even numbers list:',odd_even(number))

#### Output:

C:\Users\Pramod\PycharmProjects\pythonProject\venv\Scripts\python.exe C:/Users/Pramod/PycharmProjects/pythonProject/main.py

Odd and even numbers list: [[1, 3, 15, 7, 9], [2, 12, 6, 8]]

Process finished with exit code 0

Learn Complete Python In Simple Way

Click on enroll Button and watch the sample video then Go for Paid if you like.**Recommended Post:**

- Python Hello World Program
- Python Comment | Creating a Comment | multiline comment | example
- Python Dictionary Introduction | Why to use dictionary | with example
- How to do Sum or Addition in python
- Python Reverse number
- find the common number in python
- addition of number using for loop and providing user input data in python
- Python Count char in String
- Python Last Character from String
- Python Odd and Even | if the condition
- Python Greater or equal number
- Python PALINDROME NUMBER
- Python FIBONACCI SERIES
- Python Dictionary | Items method | Definition and usage
- Python Dictionary | Add data, POP, pop item, update method
- Python Dictionary | update() method
- Delete statement, Looping in the list In Python
- Odd and Even using Append in python
- Python | Simple Odd and Even number

Get Salesforce Answers

## 1 thought on “Odd and Even using Append in python”