Советы по аннотациямPython

Программы на Python
Anonymous
Советы по аннотациям

Сообщение Anonymous »

Хорошо, я аннотировал почти все в своем коде, но у меня немного возникают проблемы с аннотированием цикла for, у меня есть все, кроме этих двух строк, я просто не знаю, как это объяснить. смысл для всех, кроме меня. Было бы здорово, если бы я мог получить несколько советов по этому поводу!
y = {} #
Positions = [] #
for i, word in enumerate (Sentence): #This starts a for look to go through every word within the variable 'Sentence' which is a list.
if not word in y: #This continues the code below if the word isn't found within the variable 'y'.
y[word] = (i+1) #This gives the word that wasn't found within the variable 'y' the next unused number plus 1 so that it doesn't confuse those unfamiliar with computer science starting at 0.
Positions = Positions + [y[word]] #This sets the variable 'Positions' to the variables 'Positions' and '[d[word]]'.


Подробнее здесь: https://stackoverflow.com/questions/361 ... ation-tips

Вернуться в «Python»