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.
laundry list of annoyances while solving:
You can simnplify your code by using list comprehension for creating 'phrase_list' and 'new_indexes'. You could also use enumerate(indexes) to loop through the indexes and insert the word at a specified location.
Very interesting kata, challenging excersice, congratulations.
The result of most solutions can be read multiple times through
__iter__
and__next__
methods used infor
loops.Perhaps there should be tests for that?
that's because in your init the list is probably pointing towards the base list, so when you delete in the object you also delete in the base list (what happens: a[0] returns 1 and deletes 1 from the a list and from the base list so base[0] returns 2 instead of 1). To avoid this, you need to do a "copy" of the base list without reference by doing something like this : self.list = baselist[:]
yes, thanks :)
Is this enough? https://www.codewars.com/kumite/627bfcb08cb0410023aea688?sel=627bfcb08cb0410023aea688
description should be updated for Python 3;
print
is no longer a statement, it's a functionI'm stuck on the same problem/bug. I believe the test cases are ok, as it was corrected few times, maybe i miss something, could anyone explain to me why the tests return different values?
In a list [1, 2, 3, 4] we get index 0:
List returned wrong value.: 1 should equal 2
The tests are passing the 'base'-list as a reference to your function, which means that the 'base'-list will be modified if your function doesn't copy it before usage.
I am having the same problem as jgarwin95. My code does what it says in the description. After defining a = [1, 2, 3, 4], calling a[0] returns 1 and calling it again returns 2 (since a[0] is deleted after the first calling). However, I get an error saying '1 should equal 2' for the first case, and '2 should equal 4' in the second case. Any ideas on why this might be the case? If you need to see my code, let me know and I can copy and paste it.
And just to see what happens, I redefined my code so that when a[index] is called, it returns (and pops) a[index+1], i.e the output would be 2 in the first case. However, now the test case gave an error saying '2 should equal 1' !!!!
This issue is not fixed.
Once correct solution is when
word
is inserted before word with the same index and another time is correct when it is after word with the same index, why???Any advise, will be appreciate
This comment is hidden because it contains spoiler information about the solution
I like this kata. I just find a way to insert by index ^-^)
Loading more items...