Computer Science, Python.
Write a program to increment the elements of the list with a number?
Answers
n = int(input("Enter the number of elements to be entered in the list: "))
print()
l = list()
for i in range(n):
x = int(input("Enter the element: "))
l.append(x)
print()
print("Original list: ", l)
print()
icn = int(input("Enter the number by which each element needs to increment: "))
print()
for i in range(len(l)):
l[i] = l[i] + icn
print("New list: ", l)
Question :-
Write a program to increment the elements of the list with a number.
AnsweR :-
The python program for increment the elements of the list with a number -
n = int(input ("Enter the number of elements of the list - "))
print()
l = list ()
for i in range(n)
x = int(input("Enter the elements = "))
l.append(x)
print()
print ("original list = " l)
print()
increament = int(input ("Enter the number of increment in each element ="))
print()
for i in range( len(l)) :
l[I] = l[i] + increament
print("New list = " l)
_____________________________