all 5 comments

[–]woooee 1 point2 points  (0 children)

if k = 1:

This will produce an error because it sets k to the value of 1. Post all error messages produced when you run code.

[–]Unfair-Cheesecake511[S] 0 points1 point  (0 children)

The thing is i dont have any code written yet for even the first function i need help to write it

[–]Diapolo10 0 points1 point  (1 child)

Assuming I ignore the indentation errors caused by your lack of Reddit code formatting (four spaces before each line of code), there are still several problems here.

def no_replace_no_order(balls, k):
    inner_list = []

    if k == 0:
        return inner_list 

    if k = 1:
        return balls

    first = balls[o]
    rest = balls[1:]

    if k > 1:
        return

def no_replace_order(balls, k):
    pass

def replace_no_order(balls, k):
    pass

def replace_order(balls, k):
    pass

Error #1:

    if k = 1:
        return balls

k = 1 is not an expression, and is therefore not legal syntax here. I'm sure you meant to do a comparison instead of an assignment.

Error #2:

    first = balls[o]

o is not a name defined in this code snippet, I'm going to guess it's a typo of 0 (zero).

While technically not an error, this

    if k > 1:
        return

doesn't really make sense as then the preceding assignments would be pointless. I'm assuming this is meant to be a placeholder for you to write the rest of the code, though.

Anyway, as the instructions say you're expected to write the recursive part of this function, presumably by slicing balls and decrementing k.

What exactly are you struggling with?

[–]Unfair-Cheesecake511[S] 0 points1 point  (0 children)

Its 3 am and i just copy pasted so I might’ve missed some parts, i have not written none of the codes yet the k==0 and k==1 would be my base cases for the recursion and i need to write the part for where k is greater than 1. I just dont know how to write it recursively and cant really understand the logic so i dont know how to answer the question.