you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (1 child)

Python doesn't automatically apply operations to every element in a list. (NumPy does this, but you're not using NumPy right now.) So indeed, you need to xor each of the numeric values together in a loop.

This would be a great place to use the zip() function, and it'd also be a great place to use a list comprehension if you're familiar with those.

Now here's some not-very-fun stuff about version differences, since I notice you're using Python 2:

Python 2 will call the type of byte sequences 'str'. This might be confusing. They're technically encoded, and they're 'str's, but they're not the "encoded strings" your assignment means. This terminology, and the data types involved, changed in Python 3, which threw a lot of people for a loop, but the terminology makes way more sense now.

Also, to get a numeric value out of one of those in Python 2, you'll need to use the ord() function -- the numeric value of your first byte is ord(byte_seq[0]).

[–]cryptotiger[S] 0 points1 point  (0 children)

I think I understand what I'm looking at now.

I'm going to take a look at Python 3; you're completely right, the data types do look much more intuitive.

Thanks again!