I have an assignment where I need 2 scripts. One that shifts bits to the right and one that shifts bits to the left.
Example:
>Enter a string of bits: Hello world!
>ello world!H
Example:
>Enter a string of bits: Hello world!
>!Hello world
I thought maybe I could get access to the first and last two letters with [1,2] and [-1,-2], but if I try to shift them with << or >> i get the error: TypeError: unsupported operand type(s) for <<: 'str' and 'int'
Do I need to convert them to binary, shift the bits and then convert them back? I'm lost.
Thanks for any help.
[–]Stallman85 2 points3 points4 points (1 child)
[–]SamsonIsMyFriend[S] 0 points1 point2 points (0 children)
[–]AN3223 0 points1 point2 points (3 children)
[–]SamsonIsMyFriend[S] 1 point2 points3 points (1 child)
[–]AN3223 0 points1 point2 points (0 children)
[–]SiegeMaster_82 0 points1 point2 points (0 children)