Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda enumerate() | For Loops
Python Loops

bookenumerate()

In case if you need extract both index and value from the iterable object, use enumerate():

123
nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29] for idx, val in enumerate(nums): print(f'{idx}th prime number is: {val}')
copy
Tarefa

Swipe to start coding

Given a list of movies in the cinema. Starting with index 0, each element in the array is the name of the movie in production on the i-th day. Transform this data by creating a dictionary schedule that for each movie as key stores the list of days when this movie screenings are. For example:

movies = ['Shrek', 'Snow White', 'Cars', 'Cars', 'Shrek', 'Shrek 2'] =>

schedule = {
    'Cars': [2, 3],
    'Shrek': [0, 4],
    'Shrek 2': [5],
    'Snow White': [1]
}

Remember about case if movie is not in dict already.

Solução

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 3. Capítulo 3
single

single

Pergunte à IA

expand

Pergunte à IA

ChatGPT

Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo

Suggested prompts:

Resumir este capítulo

Explicar o código em file

Explicar por que file não resolve a tarefa

close

Awesome!

Completion rate improved to 6.25

bookenumerate()

Deslize para mostrar o menu

In case if you need extract both index and value from the iterable object, use enumerate():

123
nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29] for idx, val in enumerate(nums): print(f'{idx}th prime number is: {val}')
copy
Tarefa

Swipe to start coding

Given a list of movies in the cinema. Starting with index 0, each element in the array is the name of the movie in production on the i-th day. Transform this data by creating a dictionary schedule that for each movie as key stores the list of days when this movie screenings are. For example:

movies = ['Shrek', 'Snow White', 'Cars', 'Cars', 'Shrek', 'Shrek 2'] =>

schedule = {
    'Cars': [2, 3],
    'Shrek': [0, 4],
    'Shrek 2': [5],
    'Snow White': [1]
}

Remember about case if movie is not in dict already.

Solução

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

close

Awesome!

Completion rate improved to 6.25
Seção 3. Capítulo 3
single

single

some-alt