Write your own generator function that functions as the internal enumerate function. Using the function like this:
lessons = ["Why Python Programming", "Data Types and Operators", "Control Flow", "Functions", "Scripting"]
for i, lesson in my_enumerate(lessons, 1):
print("Lesson {}: {}".format(i, lesson))
should result in exit:
Lesson 1: Why Python Programming
Lesson 2: Data Types and Operators
Lesson 3: Control Flow
Lesson 4: Functions
Lesson 5: Scripting
"So, guys, I'm having a lot of trouble on this subject (generators), I can not figure out how to solve this problem, I think I should use the enumerate () function but my lack of understanding of the subject is compromising my attempts. "
lessons = ["Why Python Programming", "Data Types and Operators", "Control Flow", "Functions", "Scripting"]
def my_enumerate(iterable, start=0):
# Implement your generator function here
for i, lesson in my_enumerate(lessons, 1):
print("Lesson {}: {}".format(i, lesson))