Almost all list exercises follow the same scheme: read values into a list, go through it and show the result.
Reading n values
numbers = []
for _ in range(5):
numbers.append(int(input()))
print(numbers)
The list is created empty before the loop and each turn adds a value with append. If the program first asks how many values there will be, use that number in range:
n = int(input())
numbers = []
for _ in range(n):
numbers.append(int(input()))
Going through the elements
for n in numbers:
print(n * 2)
Going through with the index
When you need the position (for example, to show "position 0: 4"), use enumerate or range(len(...)):
for i, n in enumerate(numbers):
print(i, n)
for i in range(len(numbers)):
print(i, numbers[i])
Showing a list
print(list) writes brackets and commas. For a clean output there are several options:
l = [4, 8, 15]
print(*l) # 4 8 15 (each element as an argument)
print(*l, sep="\n") # one per line
print(" ".join(str(n) for n in l)) # 4 8 15 (join needs texts)
print(", ".join(map(str, l))) # 4, 8, 15
This will help you in Search even numbers (showing the results on one line) and in Reverse order array.
Reading until an end marker
If you do not know how many values there will be, read in a while until a stop word or value:
numbers = []
text = input()
while text != "end":
numbers.append(int(text))
text = input()
It is the pattern of Search an array of integers, where after storing the numbers, queries are made until end is received.