Regular Expressions

From Biolecture.org
import sys
import re
while True:
    my_degree=input("Enter a degree:")
    cond1=".[c]"
    cond2 = ' .[f]'

    regexp1 = re/compile(cond1, re.IGNORECASE)
    result = regexp1.search(my_degree)

    regexp2 = re.compile(cond2, re.IGNORECASE)
    result2 = regexp2.search(my_degree)

    if result1 :
        degree = float(my_degree[0:len(my_degree)-1])
        f = (9/5)*degree+32
        print('%0.2f'%f, 'F', sep='')
        break
    elif result2 :
        degree =  float(my_degree[0:len(my_degree)-1])
        c= (5/9)*degree-32
        print('%0.2f'%f, 'C', sep='')
        break
    else:
        continue