Skip to content

Commit 6c8357f

Browse files
Added comments in currency convertor main.py file for more readeability of code
1 parent 08a5ab2 commit 6c8357f

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

currency converter/main.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@
99

1010

1111
def getVal(cont1, cont2):
12+
# Extract currency codes from user input (format assumed like "USD- United States Dollar")
1213
cont1val = cont1.split("-")[1]
1314
cont2val = cont2.split("-")[1]
1415
url = f"https://free.currconv.com/api/v7/convert?q={cont1val}_{cont2val}&compact=ultra&apiKey=b43a653672c4a94c4c26"
1516
r = httpx.get(url)
1617
htmlContent = r.content
1718
soup = BeautifulSoup(htmlContent, "html.parser")
1819
try:
20+
# Extract the numeric value from the response text
1921
valCurr = float(soup.get_text().split(":")[1].removesuffix("}")) # {USD:70.00}
2022
except Exception:
2123
print("Server down.")

0 commit comments

Comments
 (0)