In python how do i divide variables in a list by a float?

Maybe this is the code you want:

def exchangeTable(euro_range):
    if euro_range < 0:
        raise Exception('Received negative range: {0}'.format(euro_range))
    if euro_range == 0:
        print('0 euros = 0 pounds')
        return
    exchange_rate = 1.15
    pounds = 1 / exchange_rate
    print ('1 euro = {0} pound'.format(pounds))
    if euro_range > 1:
        for i in range(2, euro_range + 1):
            pounds = i / exchange_rate
            print('{0} euros = {1} pounds'.format(i, pounds))

Leave a Comment