8. Write a python program to generate a function to print out the odd number from a given list, list_a as provided in the following output.
The output is:
list_a = [3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
Expected Answer:
The odd numbers: [3, 5, 7, 9, 11]
Sample Answer:
def odd_num(l): result = [] for i in l: if i % 2 != 0: result.append(i) return result print("The odd numbers:", odd_num([3, 4, 5, 6, 7, 8, 9, 10, 11, 12]))
More Exercises:
Python String ExercisesMore Numpy Exercises:
Numpy String ExercisesMore Pandas Exercises:
Pandas Series ExercisesMore Tutorials:
Python Installation - Linux (Ubuntu)