I have a list
[7, 100, 83, 1000, 9, 100, 19] I need to multiply by one hundred only those numbers, after which comes the number one hundred. It should work out like this:
[700, 83, 1000, 900, 19] I try to make it through this code:
stack2 = [] i = 1 while i < len(stack): if stack[i] == 100: stack2.append(stack[i-1]*100) elif len(stack) == 2 and i == len(stack)-1: # Гдето здесь ошибка есть stack2.append(stack[i-1]) stack2.append(stack[i]) elif i == len(stack)-1: stack2.append(stack[i]) elif stack[i-1] != 100: stack2.append(stack[i-1]) i += 1 Tell me how best to do it.
[7, 100, 100]? - Sergey Gornostaev