Calling functions
<p>this may sound proper nooby, but I'm having some trouble with python functions.</p>

<p>i do a level computer science and I'm making a currency converter using a dictionary to define the exchange rates of the currencies.</p>

<p>for each conversion, i have made a function that does all the calculations etc for the converting. for example, if i wanted to convert sterling to euro, my script would use the SE function. after i have defined all the functions, there is a algorithm that says </p>

<pre><code>if (i == 'SE'):
    return(SE)
</code></pre>

<p>because SE is the function name for this conversion. however, when i run this code, it tells me that <code>return</code> cannot be used outside of a function, so is there a way in calling up the function?</p>

<p>my code without using functions can be found here: <a href="http://pastebin.com/bt23MeTn" rel="nofollow">http://pastebin.com/bt23MeTn</a></p>

<p>my code with the function attempt can be found here: 
<a href="http://pastebin.com/sLFwrDT8" rel="nofollow">http://pastebin.com/sLFwrDT8</a></p>

<p>for those of you who are wondering why I'm using a dictionary, its because my teacher said that the exchange rates can change anytime so using a dictionary will mean the user only has to change the dict entry instead of changing each individual formula. i suppose i could make a scraper algorithm to scrape a website for each rate, but that'll probably be in my next version :)</p>

<p><code>return</code> is used to return variables from a <a href="https://docs.python.org/3/tutorial/controlflow.html#defining-functions" rel="nofollow">function definition</a>. </p>

<p>To call a function you have simply to write the name of the function with the input parameters in the round brackets. In your case <code>SE</code> function has not input parameters so you have to call it as follow:</p>

<pre><code>if i == 'SE':
    SE()
</code></pre>

python dictionary python-3.5.2