Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
What you have to do is this: your function
add(n)
needs to return a new function, let's call itaddn
. This new functionaddn
takes a parameter, let's call itk
, and it addsk
ton
, with the output beingk+n
.If you call
add(3)(4)
, Theadd(3)
part returns the functionaddn
, and thenaddn(4)
adds 3 to 4, returning 3+4. Your job is just to return what I'm callingaddn
.If you've never seen functional programming before, it may be hard to grasp the concept, but the coding here is really basic (in Python you can do this in 1 line, if you know about lambda expressions).
Right, good point, I changed it to
s
instead.One problem here is that when you're doing
s.lower()
you're not assigning that to anything. Doings.lower()
does not changes
; it returns a new string with all letters lowercase. To save that new string you should assign it. If you print yourlist_s
you'll see that the first 'T' remains uppercase. You're getting away in the test case because there's another copy of 't', but that won't happen for other test cases.I added error messages to the test cases. That should help you figure out which case your code is failing.
So it passes all the example test cases but doesn't pass after you submit? That's strange because the other test cases are all very similar to the example ones. Do you get an error message or does your code simply fail the test?
Right, I fixed that. Thanks!
The problem is that
s
is only composed of characters from the alphabet, butstring
can consist of numbers as well (it says in the description: "a palindrome is a word, phrase, number, or other sequence of symbols or elements..."). So if you changec.isaplha()
toc.isalnum()
it should work.I added an example test case that includes numbers to clarify that
string
can have numbers. Thanks for pointing that out!