title: What is the best way to validate user input against the contents of a list?
body: <p>Pretty much a Python newbie here and trying to learn. I have a script that a colleague started and I'm working on adding new functionality to it. I'd like to validate that a user input is within one of two lists I have.</p>
  
  <p>I have a raw input from the user asking for a site name and I'd like to add code that will check if the user's input is within the pre-defined lists sites_2017 and sites_2018 (which are used later in the code), then return an error if it isn't or proceed with the rest of the script if it is. I've been searching around and have seen lots of different while loop answers as well as functions, but none so far that reference multiple lists to match against.</p>
  
  <p>Just trying to wrap my head around this and figure out the best code for it as well as where in the current code a while loop, etc would need to go.</p>
  
  <pre><code># Ask user input for what they'd like to do? Render or audit? _Step user through process_
  
  import os
  import subprocess
  
  getuser = raw_input("Please enter your username :")
  
  print("1. render_device")
  print("2. audit_deivce")
  askuser = raw_input("Would you like to render_device or audit_deivce? : ")
  
  #Render:
  
  if askuser == "1":
          get_site_name = raw_input("Please enter the site name you'd like to render :")
  
          sites_2017 = ["bob", "joe", "charlie"]
          sites_2018 = ["sarah", "kelly", "christine"]
  </code></pre>