On 2021-01-10, Chris Angelico <ros...@gmail.com> wrote: > > Trace it through, step by step. You have a series of ASCII values, > represented in binary, and then you call int() on each of them. What > sort of numbers will you get? >
I'm kinda lost here about what sort of numbers I get, its class 'int'. > Then look at what chr() does when given those sorts of numbers. > > BTW, it may be helpful to look at the repr of the final string, rather > than simply printing it out. (It also may be unhelpful. If so, don't > worry about it.) > That was quite interesting text = b'This is a string' text2 = 'This is a string' res = ' '.join(format(ord(i), 'b') for i in text2) k= res.split(' ') for i in k: w= k.index(i) k[w]= int(i) s = k[0] print(type(s)) print(f'{s!r}') l = text[0] print(f'{l!r}') # output I've got: <class 'int'> 1010100 84 -- Thanks -- https://mail.python.org/mailman/listinfo/python-list