# Python program to print odd Numbers in a List
# list of numbers
list1 = [10, 21, 4, 45, 66, 93]
# iterating each number in list
for num in list1:
# checking condition
if num % 2 != 0:
print(num, end = " ")
Python program to count Even and Odd numbers in a List
# Python program to count Even
# and Odd numbers in a List
# list of numbers
list1 = [10, 21, 4, 45, 66, 93, 1]
even_count, odd_count = 0, 0
# iterating each number in list
for num in list1:
# checking condition
if num % 2 == 0:
even_count += 1
else:
odd_count += 1
print("Even numbers in the list: ", even_count)
print("Odd numbers in the list: ", odd_count)
# Python program to print all ODD numbers in the range[a, b]
a, b = (7, 19)
for num in range(a, b+1): # b+1 is to include b itself
if num & 1:
print(num, end = ' ')
# output:
# 7 9 11 13 15 17 19
#Python program to print
#even numbers in a list using recursion
def evennumbers(list, n=0):
#base case
if n==len(list):
exit()
if list[n]%2==0:
print(list[n], end=" ")
#calling function recursively
evennumbers(list, n+1)
list1 = [10, 21, 4, 45, 66, 93]
print("Even numbers in the list:", end=" ")
evennumbers(list1)
#this code is contributed by Shivesh Kumar Dwivedi
# Python program to print Even Numbers in a List
# list of numbers
list1 = [10, 21, 4, 45, 66, 93]
# iterating each number in list
for num in list1:
# checking condition
if num % 2 == 0:
print(num, end=" ")