In: Computer Science
Write a Python function that will do the following:1. Ask the user to input an integer which will be appended to a list that was originally empty. This will be done 5 times, meaning that when the input is complete, the list will have five elements (all integers).2. Determine whether each element is an even number or an odd number3. Return a list of five-string elements "odd" and "even" that map the indexes of the elements of the input list, according to whether these elements are even or odd numbers. For example: if the input sequence is 10, 7, 9, 51, and 100, the function will return the list ["even", "odd", "odd", "odd", "even"].
Code for above problem :-
def even_odd():
# empty list to store the input integers
listNumber = []
# empty list to store the even or odd keyword
listkeyword = []
# running loops 5 time and asking integer
for i in range(5):
print("Enter 5 integers to find out even odd ")
n = int(input("Enter integer {} : ".format(i+1)))
listNumber.append(n)
# checking the integer for even or odd and storing them in output list
for i in range(5):
if listNumber[i]%2==0:
listkeyword.append("even")
else:
listkeyword.append("odd")
print(listkeyword)
return
even_odd()
Screenshot For above problem :-
Output For above code :-