Write a python function to find and print longest continous odd sequence of a list of numbers given


Topic: Write a python function to find and print longest continous odd sequence of a list of numbers given

Solution

def longest_continuous_odd_subsequence(array):
    final_list = []
    temp_list = []
    for i in array:
        if i%2 == 0:
            if temp_list != []:
                final_list.append(temp_list)
            temp_list = []
        else:
            temp_list.append(i)
    if temp_list != []:
        final_list.append(temp_list)
    result = max(final_list, key=len)
    print(result)
	



List all Python Programs