mardi 14 juillet 2020

How do I get a python program to do the opposite in a for loop/if statement?

how do I get a Python for loop/if statement to do the opposite? Namely, I would like the loop below, just adding an additional statement in the third row (between the if statement and the print statement, without changing the first, second and fourth row) to print a, p, p, e.

for i in "apple":
    if i == "l":
        # additional statement here
    print(i)  

Can you please let me know? Thank you very much

Aucun commentaire:

Enregistrer un commentaire