In this Python list program, we will take a user input as a list and insert the given string at the beginning of the list elements with the help of the below-given steps.
Insert a string at the beginning of list elements:
Steps to solve the program
- Take a list as input.
- Add ‘sqa’ at the beginning of every element of the list.
- Use the list comprehension method for this purpose.
- Use for loop to iterate over elements in the list.
- During the loop add ‘Sqa’ to each element using the .format() method.
- Print the output to see the result.
#Input list
list1 = [1, 2, 3, 4, 5]
#Printing output
print(['Sqa{0}'.format(value) for value in list1])
Output :
['Sqa1', 'Sqa2', 'Sqa3', 'Sqa4', 'Sqa5']
Related Articles
Python program to iterate over two lists simultaneously and create a list of sublists.
Python program to move all positive numbers on the left side and negative numbers on the right side.
Python program to move all zero digits to the end of a given list of numbers.
Python program to find the list in a list of lists whose sum of elements is the highest.
Python program to find the items that start with a specific character from a given list.
Python program to count empty dictionaries from the given list.