Ask coding questions

← Back to all posts
how do we number the list if we are doing it in a tupil
mahitaravi (0)

for eg:
wizard=['spells','books','hogwarts']
it would be printed as
1 spells
2 books
3 hogwarts

Comments
hotnewtop
mahitaravi (0)

Thanks for your comments

LAMAQDAHODWALA (64)

You can use the enumerate class. This returns a list of tuples with the index starting at 0.

Wumi4 (557)

Use for i, x in arr.

Example: