Hey,
If i use a try/except clause to get around something like a TypeError, will that immediately bust me out of a while loop?
If so, is there any way i can tell it to stay in the while loop until its completed.
here's what I'm doing:
thanks for all of your help
If i use a try/except clause to get around something like a TypeError, will that immediately bust me out of a while loop?
If so, is there any way i can tell it to stay in the while loop until its completed.
here's what I'm doing:
Code:
>>> stuff2 ['0.53', '0.36', 'n/a', '0.45', '0.60'] >>> aa = 0 >>> bb = 1 >>> sub = [] >>> while bb < len(stuff2): ... try: ... sub.append(float(stuff2[bb]) - float(stuff2[aa])) ... bb += 1 ... aa += 1 ... try: ... sub.append(float(stuff2[bb]) - float(stuff2[aa])) ... bb += 1 ... aa += 1 ... except ValueError: ... sub.append("error1") ... bb += 1 ... aa += 1 ... except TypeError: ... sub.append("error2") ... bb += 1 ... aa += 1 ... Traceback (most recent call last): File "<interactive input>", line 3, in <module> ValueError: invalid literal for float(): n/a >>> sub [-0.17000000000000004, 'error1'] >>>
Comment