The problem with your code is that you are re-initializing the list in every iteration and hence once the loop is done the last list is printed.
Here is the fixed version of the code
totalNum = int(input("No of people?"))
name_list = []
for _ in range(totalNum):
name = input("Name?")
name_list.append(name)
print(name_list)
Also note the use of _
here, it is a special throw away variable in python which you use if just need a dummy variable to loop over a sequence.
Also you don't need to initialize the range
like range(1,totalNum+1)
, since python sequences always start from 0 you can do range(totalNum)
.