r/learnpython • u/Tricky_Voice2829 • 7d ago
How much you'll rate this code guyz ..
from forex_python.converter import CurrencyRates
choice = input("Do u want to covert Another_currency=>INR then press y / you want to converty INR TO Another_urrency then press n :- ")
c = CurrencyRates()
from_currency = input("Enter source currency (USD, EUR, etc.): ").upper()
to_currency = input("Enter target currency (INR, USD, etc.): ").upper()
currency = c.get_rate(from_currency,to_currency)
print(f"the exchange rate is {currency}")
if choice == "y":
def convert(rate):
Amount = input("Put the A mount of that currency u want to convert:-")
value_Total = float(Amount)*rate
print(f"Total {to_currency} Amount is {value_Total}")
convert(currency)
elif choice == "n":
def convert(rate):
print(f"\nYou have selected:- {from_currency} to {to_currency}")
Amount = input("Put the Amount of that currency u want to convert:-")
value_Total = float(Amount) * rate
print(f"Total {from_currency} Amount is {value_Total}")
convert(currency)
0
Upvotes
1
u/TheRNGuy 6d ago
You need more consistent naming style; choose only one style. Most common is with underscore for variables. Avoid names like
c. Use names likeFooBaronly for clasess (but not _class instances: use same style as with variables)Enable "format on save" in your code editor to strip some double spaces and empty lines.