[Python] python else statement causes a continuous loop

Discussão em 'Python' iniciado por Stack, Janeiro 17, 2025.

  1. Stack

    Stack Membro Participativo

    Not understanding why my Python else statement is causing an infinite loop?

    m = 0
    while m < len(dataframe):
    if dataframe['firstname'].iloc[m] == 'Donald':
    dataframe.loc[m, 'lastname'] = 'Trump'
    elif dataframe['firstname'].iloc[m] == 'Joe':
    dataframe.loc[m, 'lastname'] = 'Biden'
    elif dataframe['firstname'].iloc[m] == 'Barrack':
    dataframe.loc[m, 'lastname'] = 'Obama'
    else:
    dataframe.loc[m, 'lastname'] = 'last name does not matter'

    m+=1

    Continue reading...

Compartilhe esta Página