Pyg Latin Ending Up, use of len() clarification


#1

Hi,

I have just completed the PygLatin module and while everything went fine there is one piece of code I don’t quite understand and its this:

new_word = word[1:len(new_word)] + first + pyg

what I’m trying to wrap my head around is how does python know what the length of new_word could be if it isn’t even defined yet? In other words, why and how is it able to use itself when defining itself (that is, the variable new_word)?


#2

it can’t, the normal steps are:

new_word = word + first + pyg

then on the line after, take the slice. Then new_word is defined.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.