hey everyone,
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...
that wouldnt be too bad... if it weren't for the n/a. And its important to keep that n/a in there.
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...
Any ideas how i could get around that? Thanks
PC
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...
Code:
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...
Code:
Traceback (most recent call last): File "<interactive input>", line 4, in <module> ValueError: invalid literal for float(): n/a
PC
Comment