Help in the Python!

Asked

Viewed 286 times

0

I’m stuck in a part of the exercise and I needed someone to shed some light.

I’m not sure if I’m doing it the right way but where I’m really doubtful is how to display information in this way:

https://i.stack.Imgur.com/4PJ96.png

codigo = []
resposta = []
gabarito = []
participantes = int(input('Digite a quantidade de participantes: '))
for c in range(0, participantes):
    print('=-'*30)
    codigo.append(int(input('Digite o código do participante: ')))
    questao1 = 0
    print('=-'*30)
    for r in range(0, 10):
        resposta.append(int(input(f'Digite a resposta do participante para a questão {questao1}: ')))
        questao1 += 1
print('=-'*30)
questao2 = 0
for g in range(0,10):
    gabarito.append(int(input(f'Digite o gabarito da questão {questao2}: ')))

2 answers

3

To print on the same line, use the end="".

So to print the answers of the participants will look like this:

    # Número de participantes
    for i in range (0, participantes):
       # Respostas por participantes
       for j in range (0, 10):
          print(resposta[i][j], end="")

2

From what I could understand from the question, you want to print these values on the same line. In python it is possible to print on the same line using end="" to separate the values and prevent breaking the line the end="" accepts spaces, tab or any other character you want

for i in range(10):
    print(i ,end=": \t\t")

Browser other questions tagged

You are not signed in. Login or sign up in order to post.