+ 8
Help with code please.
I am asked to build a function that returns string in numerical order in range 1-9. My code isnât working. Any suggestions are greatly appreciated. https://code.sololearn.com/cZvP6se13gw7/?ref=app
9 Respostas
+ 20
hmmmm here is my idea.
It sorts the words by that char, which is in a set of the numbers. makes the story a bit shorter.
nice challenge by the way.
https://code.sololearn.com/c8Ybj6E3x2sR/?ref=app
+ 17
print(' '.join(sorted(s.split(), key=sorted)))
https://code.sololearn.com/cC01C3XizgIu/?ref=app
+ 13
ă Nicko12 ă , Frogged , RKK ,Vitaly Sokol , all of you with brilliant ideas and a great code. đđđđ
and BTW a real nice challenge!
+ 12
First, the reason why the if-elif-else statements wont work is because even though the list is still empty, the program will still insert an element to N index.
We insert 3 so the list will now look like this:
[3]
Next elements = 7, 1, 6, 4, 5:
[3, 7]
[1, 3, 7]
[1, 3, 7, 6] #Since 6 means insert to 5th index it will append instead of inserting between 4 and 7.
[1, 3, 7, 4, 6] #Then the 4 will insert to 3rd index.
And the sequence will insert randomly and so on...
- - - - - - - -- - - - - - - - - - - -
So I thought of doing and sorting this using Dictionary. (see the code for further explanation)
https://code.sololearn.com/cA61a1A9A0a1
+ 11
lil' hack added to your solution Franc.
https://code.sololearn.com/cRZ9L6nRijcj/?ref=app
+ 8
I added te1n0 and e1even1 to make it more interesting.
https://code.sololearn.com/c76y9DOuisbF/?ref=app
+ 6
Louis , great code đđđđ
+ 2
See this Francisco Javier
https://code.sololearn.com/cdGAVLNwuxnN/?ref=app
taking in account also no numbers and multiple numbers in each word, not only 1...9