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.
return ends a function, you would only go to the next line if it didnt return
Оставшаяся часть кода после return не будет выполнятся, программа выйдет из функции, поэтому это работает без написания else
Not sure which language you use but in JS it is not expecting an empty array.
This is the test:
return -1 is ours else
This comment is hidden because it contains spoiler information about the solution
thank you so much for explaining it !
for input A1 the test expects an output of [] ???? why ???
i keep getting this error:
Traceback (most recent call last):
File "/workspace/default/.venv/lib/python3.11/site-packages/codewars_test/test_framework.py", line 112, in wrapper
func()
File "/workspace/default/tests.py", line 22, in examples
test.assert_equals(available_moves(t[0]), t[1])
^^^^^^^^^^^^^^^^^^^^^
File "/workspace/default/solution.py", line 12, in available_moves
if (not letter.isalpha()) or (not number.isdigit()) or letter not in ['A','B','C','D','E','F','G','H'] or not 1 <= int(number) <= 8:
^^^^^^^^^^^^^^
AttributeError: 'int' object has no attribute 'isalpha'
and truly i do not understand why. ive checked my code again and again and it works fine on VsCode so i have no idea what i should change. are others experimenting the same ?
i dont understand. when i test my solution it gives me an error but with no specification at all. however when i use vscode, my code works fine. i wonder if it's because i used the numpy library... but the output has to be a 2D array so i dont get it.
There's a difference between the normal
if: else:
statement in Python and this. This is specifically what is called a "ternary operator", and it's a different syntax for a different operation (although it does similar things.https://www.geeksforgeeks.org/ternary-operator-in-python/
It's a bit of a shame that Python uses the same tokens
if
andelse
for both the conditional statement and the ternary operator - most languages don't, and it does make it confusing.i dont understand how you can write a whole line with if AND else without any ':' and it works. everytime i try to do something like that i get an error. does someone has an idea of why that is please ?
This comment is hidden because it contains spoiler information about the solution