title: How do i bypass a NameError name is not defined in python
body: <p>I have code that loops through checking users and storing the returned values in an array write them in a csv. At the moment I am getting an NameError because while it's looping the first time it's returning an empty value as there are no users to collect; I wanted to  bypass this error.
  How can I assign a value to my array for I won't get the NameError, I tried adding the second and third line that made no difference:</p>
  <pre><code>            if len(df) == 0:
                  df = &quot;N/A&quot;
              output = df.to_csv ( index=False,encoding = &quot;utf-8&quot;)
              print(output)
  </code></pre>