IF statement picking first option in currency converter (python)
<pre><code>print "Pound Sterling converter"
print "You can convert pounds to either dollars, euros or yen"

print

dollar = 0
euro = 0
yen = 0

convert_to = input ("What currency do you want to convert to? ")
amount = input("How much would you like to convert? ")

print

if convert_to == dollar:
    amount = amount * 1.3
elif convert_to == euro:
     amount = amount * 1.17
elif convert_to == yen:
    amount = amount * 133.66
else:
    print "You must pick either dollar, euro or yen."

print amount
</code></pre>

<p>I'm a beginner in Python, as you can probably tell. All I want this program to do is have the user choose a currency (convert_to) and then choose how much they want to convert (amount) and then the program will convert it for them.</p>

<p>When I run the program, the if statement does not work correctly. Instead of seeing what convert_to is, it goes through the convert_to == dollar part regardless of if you type euro or yen. The numbers they are being multiplied by are simply the conversion rates from pounds.</p>

<p>also, a side note but less important one, the final else part does not work. The program brings up a "input not defined" error instead of printing "You must pick either dollar, euro or yen."</p>

<p>Thanks in advance</p>

<p>In your case dollar, euro and yen , you have initialized to the same value that is zero.
You should assign different values , for example;</p>

<pre><code>dollar=0
euro=0
yen=0
</code></pre>

<p>Then try this</p>

<pre><code>print "Pound Sterling converter"
print "You can convert pounds to either dollars, euros or yen"


convert_to = input ("What currency do you want to convert to? ")
amount = int(input("How much would you like to convert? "))


if convert_to == "dollars":
    amount *= 1.3
elif convert_to == "euros":
    amount *=  1.17
elif convert_to == "yen":
    amount *= 133.66
else:
    print "You must pick either dollar, euro or yen." 

print amount
</code></pre>

python if-statement