Changing integer values from an if statement not working? (Python)
<p>Python newb here.  I'm looking to write an if statement that changes an integer value based upon an input and then loops the code.  Unfortunately, I have two problems:</p>

<ol>
<li>When the brightness printers after accepting an input, the value
that prints is 100 regardless of the input (-10, +10, set to 0, etc)</li>
<li>The else statement prints regardless if the user enters a value that
matches an if statement.</li>
</ol>

<p>What am I doing wrong here?</p>

<pre><code># -*- coding: utf-8 -*-

var = 1
brightness = 100

while var == 1 :  # This constructs an infinite loop

  print 'Brightness is ', brightness

  test1 = raw_input('up, down, on or off? ')

  if test1 == 'up':
     brightness = brightness + 10
     print brightness
  if test1 == 'down':
     brightness = brightness - 10
     print brightness
  if test1 == 'on':
     brightness = 100
     print brightness
  if test1 == 'off':
     brightness = 0
     print brightness
  else:
     print 'Try again'

print "Good bye!"
</code></pre>

<p>Andrew L. and Kalpesh Dusane answered this, thank you!!!</p>

<p>I needed to exchange my if for elif (else if).</p>

<pre><code># -*- coding: utf-8 -*-

var = 1
brightness = 100

while var == 1 :  # This constructs an infinite loop

  print 'Brightness is ', brightness

  test1 = raw_input('up, down, on or off? ')

  if test1 == 'up':
     brightness = brightness + 10
     print brightness
  elif test1 == 'down':
     brightness = brightness - 10
     print brightness
  elif test1 == 'on':
     brightness = 100
     print brightness
  elif test1 == 'off':
     brightness = 0
     print brightness
  else:
     print 'Try again'

print "Good bye!"
</code></pre>

<p>The code works great, thanks!</p>

python python-2.7