• # Convert String Into a Cipher of Dictionaries and Back Using "Dunder" Methods And Attributes

Hello, checkiomates๐ฑโ๐ค!

Welcome back to our weekly Python news digest. There is a series of two reversed encode/decode missions for your training and an article about "dunder" methods and attributes.

๐กTIP:

At your profile, after clicking on big percent number of your progress, you may see module and methods you have already used in your shared solutions. If you want to discover all CheckiO features, visit our tutorial. It's a longread, but it's worth it!

๐MISSION:

Cipher Dict by spark856 - Tackle the challenge of converting plain text into a nested cipher dictionary. Unleash your coding prowess as you navigate through a series of intricate steps: from encoding text to UTF-8 and converting it to hexadecimal, to meticulously organizing decimal numbers into ascending and descending blocks. Each digit serves as a key in a specific nested dictionary.

`get_cipher("hello") == {4: {4: {8: {3: {7: {0: {4: {}, 7: {}}, 2: {2: {}}}, 8: {3: {}}}}}}}`

Cipher Dict (decryption) by spark856 - Prepare to exercise your coding finesse as you traverse through the intricacies of reversing the encryption process. From meticulously sorting keys in the correct order to adeptly navigating through alternating blocks of digits, each step unveils a piece of the puzzle. As you merge the decoded blocks into a decimal number, the true essence of the message begins to surface. Finally, with a stroke of conversion, the decimal transforms into a hexadecimal string, revealing the secrets embedded within the encrypted text.

`get_plain({1: {6: {3: {}}},2: {6: {5: {}}, 9: {0: {}, 5: {}}},3: {4: {5: {}}},6: {6: {4: {}}}}) == 'python'`

๐ARTICLE:

Every dunder method in Python - Python includes tons of dunder methods ("double underscore" methods) which allow us to deeply customize how our custom classes interact with Python's many features. What dunder methods could you add to your class to make it friendly for other Python programmers who use it?

๐ฉโ๐ปCODE SHOT:

How do you think, what the following code does?

```def ??????????(num: int) -> bool:

l = len(text := str(num))

return sum(map(lambda i: int(i)**l, text)) == num
```