'Valuation' in Python error
Posted: Tue Apr 06, 2010 12:44 am
I'm trying to solve the 'Valuation' challenge using Python, but i keep getting the answer to be 26.
I'm sure there is an obvious error in my logic, but i can't seem to figure it out. Here is my code....
------------------------------------------------------------------------------------------------------------------
mainvalue = [9,3,7,5,2,"x","x","x",7,4,6,etc...](I'm not putting the whole value here, that would be rediculous)
countervalue = 0
lenvalue = len(mainvalue)
total = 0
while countervalue < lenvalue:
if mainvalue[countervalue] == "x":
mainvalue.insert(countervalue, 0)
countervaule = countervalue - 2
else:
total = total + mainvalue[countervalue]
countervalue = countervalue + 1
if countervalue == lenvalue:
print total
------------------------------------------------------------------------------------------------------------------
I greatly appriciate any help, btw my indentation is correct it didnt copy right
I'm sure there is an obvious error in my logic, but i can't seem to figure it out. Here is my code....
------------------------------------------------------------------------------------------------------------------
mainvalue = [9,3,7,5,2,"x","x","x",7,4,6,etc...](I'm not putting the whole value here, that would be rediculous)
countervalue = 0
lenvalue = len(mainvalue)
total = 0
while countervalue < lenvalue:
if mainvalue[countervalue] == "x":
mainvalue.insert(countervalue, 0)
countervaule = countervalue - 2
else:
total = total + mainvalue[countervalue]
countervalue = countervalue + 1
if countervalue == lenvalue:
print total
------------------------------------------------------------------------------------------------------------------
I greatly appriciate any help, btw my indentation is correct it didnt copy right