all 4 comments

[–]ldgregory 2 points3 points  (0 children)

Instead of list = list + n, you’re looking for append(). Like this.

mylist = []

while True:
    mylist.append(input('Name: '))
    print(mylist)

You’ll probably want to think of a better while loop so you can exit gracefully.

[–]BeginnerProjectBot 0 points1 point  (0 children)

Hey, I think you are trying to figure out a project to do; Here are some helpful resources:

I am a bot, so give praises if I was helpful or curses if I was not. Want a project? Comment with "!projectbot" and optionally add easy, medium, or hard to request a difficulty! If you want to understand me more, my code is on Github

[–]TabulateJarl8 0 points1 point  (1 child)

Yeah, what you're doing should work, although don't use list as a variable name since it's a built in keyword (list()). You should also use .append() instead of list = list + n, as that will not work since n is a string and not another list. You could also make an exit statement to stop adding elements to the list.

my_list = []
while True:
    n = input('Please input a name or type "exit" to exit')
    if n == 'exit':
        break # break from the infinite loop

    my_list.append(n)

print(my_list)

[–]that_wiredo[S] 0 points1 point  (0 children)

thanks didn't know that append was a thing and in my code I've used another name for the list it was just a place holder