Well I was trying to solve a problem on Codewars and was able to pass all the examples set but I am still getting an error on the site.

Here is the problem:

and here is what I am getting as error:

And here is my code:

If I had to guess Code Wars is providing you with an input of ‘N’ and you are passing that input to int(), thus getting the STDERR. You might want to see if adding some validation the input is a number before passing it to int() solves the problem.

1 Like

when I am required to create a function that will take an integer as its parameter.
this is what the problem defines
def dashatize(num):

Plus I can’t find anything with a capital N in my code

It isn’t in your code, it is in the Test, see

test.assert_equals(dashatize(None),"None", "Should return None");
test.assert_equals(dashatize(0),"0", "Should return 0");
test.assert_equals(dashatize(-1),"1", "Should return 1");
test.assert_equals(dashatize(-28369),"28-3-6-9", "Should return 28-3-6-9");

So you are seeing the test.describe('Weird'), then the next test sends “None” as input.

And just for reference, these are the tests you are already passing:

test.assert_equals(dashatize(274),"2-7-4", "Should return 2-7-4")
test.assert_equals(dashatize(5311),"5-3-1-1", "Should return 5-3-1-1")
test.assert_equals(dashatize(86320),"86-3-20", "Should return 86-3-20")
test.assert_equals(dashatize(974302),"9-7-4-3-02", "Should return 9-7-4-3-02")

I am sorry but I did not get it. I am new to Python. What should I do?

And what does test.describe(Weird’) this wants me to do with my function?

Okay, so this line

if int(i) % 2 != 0:

Needs validation.

Something like

if isinstance( i, int ) and int(i) % 2 != 0:

That way, if it is a letter it will jump to g.append(i), otherwise, if it is a number, it will try % 2 and then decide where it should go.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.