i in this case is not ideal letter variable as it implies index, becasuse here it is actually a string name being iterated on (inside the lambda function)
Create a new dictionary with the merged keys and values of d and other, which must both be dictionaries. The values of other take priority when d and other share keys.
New in version 3.9.
You are sorting a list containing strings and ints. < only works on operands of the same type (unlike e.g. in JavaScript where everything is compared as string by default)
key=lambda a: (len(a), a) is the sort key, he sorts based on the length of the string first and then on the string itself that means the default sort key when sorting strings (alphabetically)
As the task wants you to start with the longest names and proceed to the shortest and also sort from z-a in case of same length he uses reverse=True to reverse the sort order on both keys
i
in this case is not ideal letter variable as it implies index, becasuse here it is actually a string name being iterated on (inside the lambda function)This comment is hidden because it contains spoiler information about the solution
The letters are in the same order, c is before d and d is before w, etc. You can merge them as I wrote them there.
Please use appropriate markdown formatting when posting code. See https://docs.codewars.com/training/troubleshooting#post-discourse.
See https://docs.codewars.com/training/training-example#debugging-a-kata and https://docs.codewars.com/training/troubleshooting#print-input.
d | other
(cf. https://docs.python.org/3/library/stdtypes.html#mapping-types-dict)
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
You are sorting a list containing strings and ints.
<
only works on operands of the same type (unlike e.g. in JavaScript where everything is compared as string by default)Looking at your solution, what was so hard about it?
as a beginer can say that this kata is still hard to those who can solve 4,5 kyu
key=lambda a: (len(a), a) is the sort key, he sorts based on the length of the string first and then on the string itself that means the default sort key when sorting strings (alphabetically)
As the task wants you to start with the longest names and proceed to the shortest and also sort from z-a in case of same length he uses reverse=True to reverse the sort order on both keys
This comment is hidden because it contains spoiler information about the solution
multiply_all([1,2,3])(2)
|
-> integer bitwise or, set union and dict mergehttps://docs.python.org/3/library/stdtypes.html#mapping-types-dict
This comment is hidden because it contains spoiler information about the solution
Loading more items...