I have a list that I am going through using list comprehension. Each time I get a a value from the list, I want to output where I currently am in the list.
So if a list has 5 items, the output would be something like this (Including my code for the list comp):
values = ['a', 'b', 'c', 'd', 'e']
modded_values = [print(val.upper()) for val in values]
So the output from print would be:
(1/5)A
(2/5)B
(3/5)C
...
I made a small function (which doesn't work), as the variable value starts from 0 each time the function is called.
def counter(l):
list_length = len(l)
current = +1
return '(' + str(current) + '/' + str(list_length) + ')'
Which would be used like this:
values = ['a', 'b', 'c', 'd', 'e']
modded_values = [print(counter(values)+val.upper()) for val in values]