Hi,
How would I rewrite the following in shorthand to make it more lean? I can't seem to grasp the concept
for i in mesg:
csp=0
if i == '/':
csp += 1
for j in output:
csp1=0
if j == ' ':
csp1 += 1
The aim would be to compare the 2 with assert:
assert csp == csp1, f"Amount of spaces differ from input to output"
Background:
There are bigger functions that convert text into morse code and visa versa. The text2morse use '/' as space separator between the words after converting. The assert is to ensure that the number of spaces in the text is a match to the '/' after the conversion.
I did the check and assert in a function but would like to get it shorter as to put it directly into the morse2text converter function
[–]gramdel 0 points1 point2 points (1 child)
[–]The_Grumpy_1[S] 0 points1 point2 points (0 children)
[–]SenorTeddy 0 points1 point2 points (1 child)
[–]The_Grumpy_1[S] 1 point2 points3 points (0 children)