3 ms·
They should have made the analogous inverse operation: '1234' / 2 = ['12', '34']
by ffhhj 4y ago
They should have made the analogous inverse operation: '1234' / 2 = ['12', '34']
- tremon 4y agoThat's not the inverse of the multiplication though. The inverse would be '33' / 2 = '3', and '1234'/2 should then probably raise a ValueError.
- bsdz 4y agoI was more expecting '1111' / 4 = '1'. This would be the inverse operation. However, it opens up even more questions like what to do if your string has mixed values etc
- ffhhj 4y agoThe string multiplication is about _joining_ strings, the inverse is about _splitting_ them in several parts. It's only confusing because the * appends the string to itself, the / is actually very clear.
- dekhn 4y agoDisagree. The inverse "string" * value is logically splitting, and then collapsing the repeated values. The logical split can be omitted, but the collapsing cannot.
- jbverschoor 4y agoNaming is hard they say
- deleted 4y ago[deleted]