6. Slide to the Left! Slide to the Right


#1

I’m not understanding what I am doing wrong here?

Error message says: “Your code looks a bit off (pun super intended)–it threw a “keyword can’t be an expression (python, line 5)” error. Check out the examples in the instructions if you need help!”

shift_right = 0b1100
shift_left = 0b1

# Your code here!
shift_right = 0b1100 >> 0b0011 (12 >> 2 = 3)
shift_left = 0b1 >> 0b100 (1 >> 2 = 4)

print bin(shift_right)
print bin(shift_left)

#2
12 >> 2 == 3  =>  True

in binary,

0b1100 >> 0b10 == 0b11  => True

The code in parentheses should be commented out.

The initial values are stored in variables, so go ahead and use those variables in your code, rather than literal values.

shift_right = shift_right >> 2

shift_left = shift_left << 2

#3

oh so I did it the unnecessary way, because i just hit "get code"
and all I needed was:

shift_right = shift_right >> 2
shift_left = shift_left << 2

rip, I get it though, thank you


#4

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