From 6c8357f3b0022056bc1f5ab20120f3714a2dc5a3 Mon Sep 17 00:00:00 2001 From: kamakshipal1-tech Date: Sat, 15 Nov 2025 00:02:58 +0530 Subject: [PATCH] Added comments in currency convertor main.py file for more readeability of code --- currency converter/main.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/currency converter/main.py b/currency converter/main.py index b656e7bdf3b..51c80445791 100644 --- a/currency converter/main.py +++ b/currency converter/main.py @@ -9,6 +9,7 @@ def getVal(cont1, cont2): + # Extract currency codes from user input (format assumed like "USD- United States Dollar") cont1val = cont1.split("-")[1] cont2val = cont2.split("-")[1] url = f"https://free.currconv.com/api/v7/convert?q={cont1val}_{cont2val}&compact=ultra&apiKey=b43a653672c4a94c4c26" @@ -16,6 +17,7 @@ def getVal(cont1, cont2): htmlContent = r.content soup = BeautifulSoup(htmlContent, "html.parser") try: + # Extract the numeric value from the response text valCurr = float(soup.get_text().split(":")[1].removesuffix("}")) # {USD:70.00} except Exception: print("Server down.")