Skip to content

Commit 87533ed

Browse files
committed
Currency Converter
1 parent 963a912 commit 87533ed

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

web_programming/currency_converter.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -173,22 +173,22 @@
173173
def convert_currency(
174174
baseCurrency: str = "USD",
175175
targetCurrency: str = "INR",
176-
amount: str = "25",
176+
amount: float = 1.0,
177177
apiKey: str = API_KEY,
178-
):
178+
) -> str:
179179
"""https://www.amdoren.com/currency-api/"""
180180
res = requests.get(
181181
f"{URL_BASE}?api_key={API_KEY}&from={baseCurrency}&to={targetCurrency}&amount={amount}"
182182
).json()
183183
if res["error"] == 0:
184-
return res["amount"]
184+
return str(res["amount"])
185185
return res["error_message"]
186186

187187

188188
if __name__ == "__main__":
189189
base_currency = input("Enter base currency: ").strip()
190190
target_currency = input("Enter target currency: ").strip()
191-
amount = input("Enter the amount: ").strip()
191+
amount = float(input("Enter the amount: ").strip())
192192
print(
193193
convert_currency(
194194
baseCurrency=base_currency, targetCurrency=target_currency, amount=amount

0 commit comments

Comments
 (0)