Aug-18-2021, 03:28 PM
Hi all! Here's some code:
Second, do Lines 11-12 make sense? I found a webpage stating that as a way to report a division-by-zero exception and thought it might work for all exceptions. It did not work here when I activated them (I don't understand them either because I've never seen a line in Python "X as y:" being short for "if X is y").
from forex_python.converter import CurrencyRates import datetime as dt from time import sleep def try_convert(country, date=''): success = False while success == False: try: res = c.get_rate('USD',country,date='') except: #Exception as e: # print(e) #wait a while print('need to sleep') sleep(10) return resFirst, did I handle Lines 5 and 9 correctly with regard to the 'date' argument?
Second, do Lines 11-12 make sense? I found a webpage stating that as a way to report a division-by-zero exception and thought it might work for all exceptions. It did not work here when I activated them (I don't understand them either because I've never seen a line in Python "X as y:" being short for "if X is y").