Complete-Python-3-Bootcamp icon indicating copy to clipboard operation
Complete-Python-3-Bootcamp copied to clipboard

summer of '69

Open lawlll opened this issue 1 year ago • 0 comments

im referring to the 'function practice solutions'

since while isnt gonna loop because of the code inside it, using if is better as it gets rid of the break statements too and does the same work but with lesser code  

def summer_69(arr):
    total = 0
    add = True
    for num in arr:
        if add:
            if num != 6:
                total += num
            else:
                add = False
        if not add:
            if num == 9:
                add = True
    return total

lawlll avatar May 17 '24 20:05 lawlll