Ad
  • Custom User Avatar

    What you have to do is this: your function add(n) needs to return a new function, let's call it addn. This new function addn takes a parameter, let's call it k, and it adds k to n, with the output being k+n.

    If you call add(3)(4), The add(3) part returns the function addn, and then addn(4) adds 3 to 4, returning 3+4. Your job is just to return what I'm calling addn.

    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).

  • Custom User Avatar

    Right, good point, I changed it to s instead.

  • Custom User Avatar

    One problem here is that when you're doing s.lower() you're not assigning that to anything. Doing s.lower() does not change s; it returns a new string with all letters lowercase. To save that new string you should assign it. If you print your list_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.

  • Custom User Avatar

    I added error messages to the test cases. That should help you figure out which case your code is failing.

  • Custom User Avatar

    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?

  • Custom User Avatar

    Right, I fixed that. Thanks!

  • Custom User Avatar

    The problem is that s is only composed of characters from the alphabet, but string 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 change c.isaplha() to c.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!