0
0
Pythonprogramming~15 mins

enumerate() function in Python - Mini Project: Build & Apply

Choose your learning style9 modes available
Using the enumerate() function in Python
๐Ÿ“– Scenario: You are helping a teacher organize a list of student names with their position numbers for attendance.
๐ŸŽฏ Goal: Build a program that uses the enumerate() function to pair each student name with their position number starting from 1.
๐Ÿ“‹ What You'll Learn
Create a list of student names
Create a variable to set the starting index for enumeration
Use the enumerate() function with the starting index
Print each student's position number and name
๐Ÿ’ก Why This Matters
๐ŸŒ Real World
Teachers, event organizers, and programmers often need to number items in a list clearly and simply.
๐Ÿ’ผ Career
Knowing how to use <code>enumerate()</code> helps in data processing, reporting, and user interface development where item positions matter.
Progress0 / 4 steps
1
Create the list of student names
Create a list called students with these exact names in order: 'Alice', 'Bob', 'Charlie', 'Diana', 'Ethan'.
Python
Need a hint?

Use square brackets [] to create a list and separate names with commas.

2
Set the starting index for enumeration
Create a variable called start_index and set it to 1 to start counting from 1.
Python
Need a hint?

Just assign the number 1 to the variable start_index.

3
Use enumerate() to pair positions with names
Use a for loop with variables position and name to iterate over enumerate(students, start=start_index).
Python
Need a hint?

Use enumerate() with the start parameter to begin counting from 1.

4
Print the position and student name
Inside the for loop, write print(f"{position}: {name}") to display each student's position number and name.
Python
Need a hint?

Use an f-string to format the output as "position: name".