Here is my current code:
My issue is, I'm practicing List Comprehension but am confused as to why "count += 1" does not work in this type of format:
[count += 1 for elem in li]
[count += 1 and print(elem) for elem in li]
I am, however, able to do it in a normal for loop as I did below. Can someone explain how I can accomplish the function below with a list comprehension?
(The above lines of code with the list comprehension format are not necessarily related to accum(s).)
def accum(s):
count = 0
li = []
for char in s:
count += 1
li.append(char.upper() + char.lower() * (count-1))
return "-".join(li)