I am trying to increment symbol by 2 in the first if statement instead of by 1, which is the default for this for loop. However, even after the if statement is true and symbol is incremented by 2, the following iteration runs as if the symbol has just been incremented by 1. So my dilemma is that even though symbol is being increased by 2, it goes back to being increased by one which makes doing symbol+=2 useless.
Is there any way of increasing symbol by 2 in the first if statement?
def solution(roman):
value = 0
for symbol in range(len(roman)):
if roman[symbol:symbol+2] == 'IV':
value+=4
symbol+=2
elif roman[symbol] == 'I':
value+=1
elif roman[symbol] == 'V':
value+=5
return value