0
I want to know:
- There is another way to access the index in question, where I am using in print()?
- Guarded in 'dice' the respective values, but because they are decimal, I’m having difficulty reporting to the user.
- Although almost ready, if possible I want suggestions for improvement.
Follows the script:
print('\n')
dados = []
for index in range(2):
print('\n') # Espaço linha
nome = input('None do Atleta: ')
nome.capitalize()
if nome < '.':
print('Reenicie o sistema, digitando o nome do atleta')
break
print('\n') # E2
distância = input('Distancia do salto: ')
dados.append(distância)
print(f'Atleta: {nome}\n')
print(f'Primeiro salto: {distância[0:2]}')
print(f'Segundo salto: {distância[2:4]}')
print(f'Dados informados: {dados[0:]}')
It has how to place a sample of data, or a specification of the data, with which to feed the algorithm?
– Augusto Vasques
Just for the record that the operation being performed is not indexing per se, but a slicing.
– Luiz Felipe
@Augustovasques, I will modify. Thank you.
– Daniel Alves de Barros
Daniel, can you give us an example of what the program entry will be? And better explain what the condition should be
if nome < '.'
?– Woss
@Woss, YES, of course. The entrance asks:
– Daniel Alves de Barros
Ask what? I guess you haven’t finished the comment.
– Woss
That one
break
within theif
makes a mistake, sincebreak
can only be inside a loop (and in the case, it is not). It is also unclear what exactly you are trying to do, because the listdados
will only have one element, and by doingdistancia[0:2]
you are accessing pieces of the string that was typed. Anyway, everything is very confusing...– hkotsubo
@Woss, YES, of course. The entry asks: the name of the athlete, later, if the name is less than '.' it will stop. That is, if the user does not enter the name of the athlete, there is no continuity. This was the way I thought for this situation. In processing, pg ira takes the typed notes, e.g., 8.4, or 3.6 (decimals) and places them in dice, then I have to return these values of note pro usuario as it is there in the print, later, it informs: first note: 3.4; second note: 8.6, so on.
– Daniel Alves de Barros
@Danielalvesdebarros, take a look in that print. Note that I modified the recoil of the code and changed
if nome < '.':
forif nome.strip() == "":
. But I’m still having a hard time understanding what you’re trying to do, because for me I would make a dictionary of jumps and each jump would treat it as a numerical value.– Augusto Vasques
"if the user does not enter the athlete’s name" - test if the name is less than
.
nay That’s what if I type;
will be considered greater than.
, for example. You would have to test whether the name is empty, as already suggested by Augusto above.– hkotsubo
And it makes no sense to type all the notes at once and save everything in the same string to then pick up pieces of it, the best is to have a list of notes (again, as already suggested)
– hkotsubo
@Augustovasques, initially I put this condition to name as 'if name == ()', but obviously, as already mentioned by you, does not. Thanks for the neat method sent 'strip'/placed track shared. I could do yes with dicio, however this is a question. But I don’t know if it will be possible, since I’m having great difficulty finding the list’s Index, ex 'print(f'First jump {distance[0:2]}'). However because it comes to decimals becomes difficult
– Daniel Alves de Barros
@hkotsubo, (interesting username that your rsrs), my dear, thank you. I already reported your note pro program and ranked you.
– Daniel Alves de Barros
From what I understand you’re trying to do something like this: https://ideone.com/mUAfIU
– Augusto Vasques