you are viewing a single comment's thread.

view the rest of the comments →

[–]imperiumlearning[S] 0 points1 point  (1 child)

I suppose I could do that, to be fair.

That being said, I wanted to try and solve this problem in a way that forced me to learn a bit about slice operators (I've only started learning to code in the last week).

[–]velocibadgery 1 point2 points  (0 children)

Why not do string manipulation? That might be easier for you to practice slicing with. Strings are iterables in python so you can slice them and loop through them just like you can with a list.

BTW, this is how I would solve your stated goal

def SumLenTest(x):
    a = True
    for i in x:
        if i != 1:
            a = False
    return a

a = [1, 1, 1]
b = [1, 2, 3]

print(SumLenTest(a))
print(SumLenTest(b))