Q:

Write a Python program to split a given list into two parts where the length of the first part of the list is given

0

Write a Python program to split a given list into two parts where the length of the first part of the list is given.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

def split_two_parts(n_list, L):
    return n_list[:L], n_list[L:]
n_list = [1,1,2,3,4,4,5, 1]
print("Original list:") 
print(n_list)
first_list_length = 3
print("\nLength of the first part of the list:",first_list_length)
print("\nSplited the said list into two parts:")
print(split_two_parts(n_list, first_list_length))

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now