I have this specific code which is meant to first convert specific currency into EUR value. This part of code has been sorted out.
country = ['CZ', 'PL']
def f(country, value):
if "PL" in country.upper():
value2 = value / 3
elif "CZ" in country.upper():
value2 = value / 20
else:
raise ValueError
round(value2, 2)
print('The conversion of ', value1, input1, 'is: ', value2, 'USD \n')
if value2 >= 20:
print('ABOVE Clip level - EU PO is required')
return ('ABOVE Clip level')
else:
print('value {} USD matches expected. BELOW Clip level'.format(value2))
return ('BELOW clip level')
while True:
input1 = str(input('Enter Currency [CZK or PLN]: '))
value1 = float(input('Enter Value: '))
try:
f(input1, value1)
break
except ValueError:
print('Some error occurred, try again.')
You will notice that the retrieved value enters a second condition: if value2 >= 20:
if value2 >= 20:
print('ABOVE Clip level - EU PO is required')
return ('ABOVE Clip level')
else: print('value {} USD matches expected. BELOW Clip level'.format(value2)) return ('BELOW clip level')
I would like to achieve a correlation between the country (or currency) and specific value. So, let's say if I would like to have: value2 = 20 as limit for country = PL; value2 = 10 as limit for country = CZ.
I understood that this should be somehow integrated in the function f but I cannot figure out how. I have tried to nest it as well as write it separately but it does not return the correct value. I guess I could create a list of clip level but seems confusing. The other option was to include a table with correspondence of value per country but honestly I have no idea if that is possible. Finally the last option (the one I am trying right now and still seem not working) is to nest a function cliplimit within the function f.
def cliplimit(cliplim):
for country in f:
if country == 'PL':
cliplim = 20
elif country == 'CZ':
cliplim = 10
else:
raise ValueError
round(cliplim,0)
return cliplim
if value2 >= cliplimit():
print('ABOVE Clip level - EU PO is required')
return ('ABOVE Clip level')
else:
print('value {} USD matches expected. BELOW Clip level'.format(value2))
return ('BELOW clip level')
So far the error I get is related to the positional argument cliplim:
line 37, in <module> f(input1, value1)
line 23, in f
if value2 >= cliplimit(): TypeError: cliplimit() missing 1 required positional argument: 'cliplim'
I hope it is not too confusing, but the juice is that I need to assign specific values to specific countries/currencies for clip limit. Thank you for any help!
Aucun commentaire:
Enregistrer un commentaire