[Python] I am not sure if i wrote my even odd while loop right [duplicate]

Discussão em 'Python' iniciado por Stack, Agosto 27, 2025.

  1. Stack

    Stack Membro Participativo

    So here is the problem: The even_or_odd_all function takes as input a list of integers and computes and returns a list containing True/False representing whether each corresponding number in the input list is even.(use While loop)

    This is my code:

    def even_or_odd_all(even_odd):
    #input is a list of integers
    #output is a list of boolean values (which depends on if the number is even or odd)
    #So this function is supposed to take in a list and return a list with booleans depending on if therye even or odd
    # i guess i needa use a while loop
    while True:
    i in (range(len(even_odd)))
    even_odd = []
    if (i % 2) == 0:
    even_odd.append(i % 2 == 0)
    return
    i = False


    however I also keep getting this error

    { Traceback (most recent call last):
    File "<input>", line 1, in <module>
    File "<input>", line 7, in even_or_odd_all
    UnboundLocalError: local variable 'i' referenced before assignment}

    Continue reading...

Compartilhe esta Página