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.
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']
Related Questions
Write a program that inputs two lists and creates a third, that contains all elements of the first followed by all elements of the second.
Ask the user to enter a list containing numbers between 1 and 12. Then replace all of the entries in the list that are greater than 10 with 10.
Write a program to check if a number is present in the list or not. If the number is present, print the position of the number. Print an appropriate message if the number is not present in the list.
Create the following lists using a for loop:
A list consisting of the integers 0 through 49.