-2
My question is how to do the line break in a list print in Python. I need to print the code working. Except the names on the list are getting too long. Every 10, the winner gets 1 coupon, so if he donates 100 his name enters the list 10 times, making a huge line has how to do a line break in the print?
listasorteio = []
while True:
print('digite sair para encerrar')
nome = input('digite o nome: ')
if nome == 'sair':
break
valordoado = int(input('Digite o valor doado: '))
valord = valordoado // 2
listasorteio.extend([nome]*valord)
print(listasorteio)
Hey buddy, it worked. Thanks.
– Old School Gamer
@You’re welcome to Oldschoolgamer. If the answer suits you, don’t forget to accept it to help future site searches.
– Naslausky
@Oldschoolgamer If you just wanted to print the names, one in each line, it’s much simpler to do
for nome in listasorteio: print(nome)
. Use comprehensilist on in this case it is an exaggeration, not to mention that another list is created unnecessarily - the brackets around the expression create a list. If you just want to print and nothing else, why create this list, and you can print everything without creating it? See also: https://answall.com/a/459289/112052– hkotsubo
right, got it and worked well too, thank you very much.
– Old School Gamer