Write a python function that takes a list of elements and n as input, extract and append first n characters and last n characters of each string and return the resultant list
Topic: Write a python function that takes a list of elements and n as input, extract and append first n characters and last n characters of each string and return the resultant list
Solution
def nchar (list1,no): return [items[:no]+items[-no:] for items in list1] list1 = ["ROHAN", "END"] nchar(list1, 3)
List all Python Programs