-1

community,

I' m a total noob concerning python and I would like to create a little name-statistic with the program. my code (I am using python 3.4.0):

while True:
    eingabe = input ('Please enter a name: ')
    print (eingabe)
    if eingabe == '':
        break

so now I would like to store the user input in a list. How can I do this?

Kind regards, Lisa

anon582847382
  • 19,907
  • 5
  • 54
  • 57

1 Answers1

1

Just define a list and then add new values to it with .append().

names = []  # Here we define an empty list.
while True:
    eingabe = input('Please enter a name: ')
    if not eingabe:
        break

    names.append(eingabe)
    print(names) # it worked for me when I used "names" to print (since I want to print the list of all the values).  Using "eingabe" did not work for me (but I may have had other conditions)
Community
  • 1
  • 1
anon582847382
  • 19,907
  • 5
  • 54
  • 57
  • thank you very much! I wasn't sure where to put the append-part! –  Mar 18 '14 at 19:45
  • @user3429227 In which case please accept the answer by clicking on the tick below the vote counts so it turns green. It indicates to other users that your problem is solved and gives me credit for being helpful. – anon582847382 Mar 18 '14 at 20:03