CBSE Class 11 Computer Science
Question 91 of 104
List Manipulation — Question 5
Back to all questions 5
Question Question 5
Ask the user to enter a list of strings. Create a new list that consists of those strings with their first characters removed.
Solution
l1 = eval(input("Enter a list of strings: "))
l2 = []
for i in range(len(l1)):
l2.append(l1[i][1:])
print("List after removing first characters:")
print(l2)Output
Enter a list of strings: ["red", "green", "blue", "pink", "cyan"]
List after removing first characters:
['ed', 'reen', 'lue', 'ink', 'yan']