Slip and Slide


#1



https://www.codecademy.com/courses/python-intermediate-en-KE1UJ/2/4

I was able to complete this lesson by looking at pass answers from other members and the directions were not very clear. I never had

mask = 0b1 << (n-1)

in my original code. However, after seeing many different people with a similar line of code i knew I was off. I just want to know how they interpreted this from the directions since i couldn't decipher this from the given text.


#2

Recall that bit-1 is zero-shift left from the right (lowest order bit). That is why we subtract 1 from n, so we don't exaggerate our left shift. If we wish to flip bit-1. the mask will be,

mask = 0b1 << 0

Shifting and indexing have similar offset intuition.

'text'[0]  == 't'

Zero offset, just as above.


#3

Thank you very much

A student from Center for Creative Arts


#4

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