pythonarrayslis

I want to get a list of strings from a user, how should i get that?


I want to get a series of strings from user and put it in a list and then print it

also i want when i put done i close the list and print it

list = []
for i in list:

    list[a]=input('the name of stings:')
    list.append(list[a])
    a +=
    print(list)

Solution

  • Try this :

    list_ = []
    not_done = True
    while not_done:
        inp = input('name of string : ')
        if inp.lower() != 'done': # Put any string in stead of 'done' by which you intend to not take any more input
            list_.append(inp)
        else:
            break
    print(list_)
    

    Output :

    name of string : sd
    name of string : se
    name of string : gf
    name of string : yh
    name of string : done
    ['sd', 'se', 'gf', 'yh']