I'm writing a function compare(list_a, list_b)
that accepts two lists of integers.
The function does the following:
- Counts the number of odd numbers in the first list
- Counts the number of odd numbers in the second list
- Returns 1, if the first list has more odd numbers
- Returns -1, f the second list has more odd numbers,
- Returns 0, if both lists have the same amount of odd numbers.
I am writing a main program that testing the function and randomly generate the list of size 15, range of integers from -10 to 10.
Here is what I have so far:
def make_list(size):
my_list=[]
for i in range(size):
my_list.append(int(input("enter integer ")))
return my_list
def compare(list_a,list_b):
flist=[]
slist=[]
fcount=0
for i in my_list:
if(i%2!=0):
flist.append(i)
fcount+=1
def main():
size=random.randint(15, -10,10)
main()
Aucun commentaire:
Enregistrer un commentaire