KnowledgeBoat Logo

Computer Science

Ask the user to enter a list of strings. Create a new list that consists of those strings with their first characters removed.

Python

Python List Manipulation

86 Likes

Answer

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']

Answered By

37 Likes


Related Questions