I pass the list to the view. My array looks like this: [football, basketball, soccer]. In my opinion, I would like to show something like this:
1. football
2. basketball
3. soccer
This means that I will have to iterate over the list that is passed to the array, do a for loop for the elements. How can I do this in a template file?
For each element, I will need to get its index and add 1 to it. Now I do not know how to do this in representations. One of the ways I thought about this is to make a dictionary, for example, {'1', 'football': '2', 'basketball': '3', 'soccer'}but since I already have the data in list format, I would prefer not to convert it.
source
share