Hello Friends, I am a novice and trying to understand how the various python functions work. Please help me understand how enumerate() function works. I have tried some code by my own to get the concepts clear. If someone can explain how the function has worked after the change, it will be helpful
<<<< CODE START >>>>
>>> def printStuff(Stuff):
"""First definition of the function"""
for i,s in enumerate(Stuff):
print("Album ", i," Rating is", s)
>>> album_ratings = [10.0, 8.5, 9.5]
>>> printStuff(album_ratings)
Album 0 Rating is 10.0
Album 1 Rating is 8.5
Album 2 Rating is 9.5
>>> def printStuff(Stuff):
"""Second definition of the function"""
for i,s in enumerate(Stuff):
print("Album ", enumerate(Stuff)," Rating is", s)
>>> printStuff(album_ratings)
Album <enumerate object at 0x0000016C807731B0> Rating is 10.0
Album <enumerate object at 0x0000016C807731B0> Rating is 8.5
Album <enumerate object at 0x0000016C807731B0> Rating is 9.5
