When I display the list in the console, it shows it with brackets and without line breaks, just everything is written in that line.

workers = ['1. Lololosh Lololoshin \n', '2. Makentosh Makentoshin \n', '3. Dratatosh Dratatoshin \n'] print(workers) who = input('Who are you: ') 

Tell me how to display it without brackets, commas in a column. If there is an option not to use lists, but something else is welcome.

  • Output in a loop and that's it. - Igor Golovin
  • @IgorGolovin do not tell me how? - user274020
  • one
    print(*workers, sep='') - godva
  • one
    print(''.join(workers)) - Sergey Gornostaev
  • one
    related question ru.stackoverflow.com/q/580971/23044 (useful to know the difference between print (text) and print (repr (text)) - jfs

1 answer 1

First, you do not need to store sequence numbers and line breaks. They can be inserted at the time of withdrawal. Secondly, if the list with names is not replenished during execution, it is better to store in a tuple:

 workers = ( 'Lololosh Lololoshin', 'Makentosh Makentoshin', 'Dratatosh Dratatoshin' ) 

And you can output in a simple loop:

 for i, w in enumerate(workers, start=1): print('{}. {}'.format(i, w)) 

Well, or the pythonic way:

 print(*['{}. {}'.format(i, w) for i, w in enumerate(workers, start=1)], sep='\n')