i'm working with a list that would be something like
xx = ['0.53', 'n/a', '0.36', '0.45', '0.60']
and i want to do some calcuations with each item, lets say subtract one item from the item prior...not bad say something like...
Expand|Select|Wrap|Line Numbers
- results = []
- while second < len(xx):
- first = 0
- second = 1
- results.append(xx[second] - xx[first])
- first += 1
- secodn += 1
what i'd like is, if the code is soppose to do soemthing like n/a - 0.53 for it to return "BadMath"...
But when i use the code above i get the following error...
Expand|Select|Wrap|Line Numbers
- Traceback (most recent call last):
- File "<interactive input>", line 4, in <module>
- ValueError: invalid literal for float(): n/a
PC