python - Python3.4-How to take a number out of a list and change to a float for math -


i have list of numbers inputted user. need able point spot in list. take number thats there, add it, , put new number in place. no matter how many different ways try tells me "typeerror: unsupported operand type(s) +: 'int' , 'list'". here code have far

itemsamt ##this list

itemsamtin ##a number inputted user

itemsamtin2 ##i added variable in attempt extract number , change float

if itemsin == 1:         itemsamt[0]         itemsamtin2 = itemsamt         itemsamtin = itemsamtin + itemsamtin2         itemsamt.insert(0,itemsamtin)         itemcost = .89 * itemsamtin         cost.insert(0,itemcost)         totalcost = totalcost + itemcost 

with line

itemsamtin2 = itemsamt 

you declared itemsamtin2 identical copy of itemsamt. itemsamtin2 becomes list itemsamt is.

if tim castelijns right presumption itemsamt[0] meant itemsamt = itemsamt[0] meant itemsamtin2 = itemsamt

itemsamtin2 = itemsamt[0] 

Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -