Ad
  • Custom User Avatar

    In java, when you divide 2 numbers with the same type, the result has the same type that the operands have.
    5 and 9 are ints, so java converts the result of 5/9 (0.5555555556) to an int using half down rounding, resulting in 0.
    But, since 5.0 and 9.0 are both floats, the result is also a float by the Java rules, so it does no conversion and the result is 0.555555556.

  • Custom User Avatar

    5/9 is 0. float(5/9) is 0.0. You probably want to use float(5)/9. i.e. Convert to float before the division.

  • Custom User Avatar

    You have to return a number, not a string.

  • Custom User Avatar

    When a parameter is called with an asterisk (*args), it can accept multiple arguments and will return the arguments as a tuple.

    If the argument tuple is nested (that is, another array is inside of it) you can call the last element in that array inside the tuple. Array[-1] gets the last item and if that item is a nested array then Array[-1][-1] will be needed to look at last element in that.

    Example:

    (5, 2, 5, [1, 2, 3, 4])[-1]  - last item in tuple is [1, 2, 3, 4] because the list counts as one item
    
    (5, 2, 5, [1, 2, 3, 4])[-1][-1]  =  [1, 2, 3, 4][-1]  - last item of the list (in the tuple) is 4
    
    so (5, 2, 5, [1, 2, 3, 4])[-1][-1] == 4
    

    TL;DR It looks at nested items from the tuple argument.

  • Custom User Avatar

    There is no special method for indentation in codewars.
    The line number is different because of some preloaded code before your solution.
    Which Kata were you doing? Could you post the solution you tried here?
    (Use proper formatting for the code), For example

    ```python
    def my_func():
      return my_val
    ```
    

    will be rendered as

    def my_func():
      return my_val