Python list comprehension - access last created element? -
Is it possible to access the previous element in the understanding of the list?
I'm working on some of the Toy Encryption Given the Key stuff as an arbitrarily large integer, an initial value, and a list of elements in the form of a message to encrypt. I need to do the X-ray with the previous cipher element and the key to the following loop.
previous = initialization_value cipher = []: element = element ^ last ^ main cipher .append (last) for the element in the message It should be possible to change the understanding of the list, but I am not sure how to handle the initial value or how to generate the previous value is generated. Is it possible and if so, what will be the sense?
There is no good, intangible way to comprehend a list with regard to understanding the list The best way to think in is in the form of a replacement for map and filters . In other words, whenever you need to take a list and
-
Use your elements as input for some expression (for example, to repay elements) < / P>
-
Remove some of its elements on the basis of some situations
What is the similarity between these things, is that they only See the same list at one time the element is a good rule of thumb; Even if you can theoryally write the code shown as a list, it will be strange and unexpected.
Comments
Post a Comment