Skip to content

Instantly share code, notes, and snippets.

@eliasalbuquerque
Created December 12, 2023 21:43
Show Gist options
  • Save eliasalbuquerque/f0c40f319d32c0bec0ee8770f5016748 to your computer and use it in GitHub Desktop.
Save eliasalbuquerque/f0c40f319d32c0bec0ee8770f5016748 to your computer and use it in GitHub Desktop.
Curso Dev Aprender | Jhonatan de Souza

Código

# DESAFIO
# Itere sobre a lista abaixo exibindo o número do índice + nome da fruta. Porém
# quando o índice for 3 exiba 'Nº índice + nome da fruta EM PROMOÇÃO'

frutas = ['maça', 'laranja', 'morango', 'limao']

for indice, fruta in enumerate(frutas, 0):
    if indice < 3:
        print(f'{indice}: {fruta}')
    else:
        print(f'{indice}: {fruta} EM PROMOÇÃO')

Console

0: maça
1: laranja
2: morango
3: limao EM PROMOÇÃO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment