title: reduce the number of IF statements in Python
body: <p>I have written a function that is going to have up to 72 IF statements
  and i was hoping to write code that will be much shorter,  but have no idea where to start</p>
  
  <p>The function reads the self.timeselect variable when a radio button is selected and the result is saved to a text file called missing_time.txt. If the result is equal to 1 then save "0000" to the file, if the result is 2 save then 0020 to the text file etc. This can be for 72 possible combinations.</p>
  
  <p>Is there a smarter way to simplify the function ?</p>
  
  <pre><code>def buttonaction():
      selectedchoice = ""            
      if self.timeselect.get() == 1:                
          selectedchoice = "0000"
          orig_stdout = sys.stdout
          f = open('missing_time.txt', 'w')
          sys.stdout = f
          print(selectedchoice)
          f.close()
      if self.timeselect.get() == 2:                
          selectedchoice = "0020"
          orig_stdout = sys.stdout
          f = open('missing_time.txt', 'w')
          sys.stdout = f
          print(selectedchoice)
          f.close()
  
  self.timeselect = tkinter.IntVar()
  
  self.Radio_1 = tkinter.Radiobutton(text="0000",variable = 
  self.timeselect,indicator = 0 ,value=1)  
  self.Radio_1.place(x=50,y=200)
  self.Radio_2 = tkinter.Radiobutton(text="0020",variable = 
  self.timeselect,indicator = 0 ,value=2)  
  self.Radio_2.place(x=90,y=200)
  </code></pre>