In: Computer Science
Post a Python program that contains an array variable whose values are input by the user. It should the perform some modification to each element of array using a loop and then the modified array should be displayed. Include comments in your program that describe what the program does. Also post a screen shot of executing your program on at least one test case.
Here is the solution. Please do upvote thank you. If you have any doubts in python I will help you can contact me.
#declare an array with variable name as sample_array
sample_array=[]
#using for loop take inputs
#prompt te user for number of iterations
print("enter number of iterations")
n=int(input())
for i in range(n):
#take input
temp=input()
#append in to the array
sample_array.append(temp)
print(sample_array)
#performing some modifications conactinate each element with string "hi"
for i in range(n):
sample_array[i]+=" hi"
#print modified array
print(sample_array)