Basic Loop/Python
<p>I am supposed to write a program that displays numbers from 100 to 200, ten per line, that are divisible by 5 or 6 but NOT both. This is my code so far. I know it's a basic problem so can you tell me the basic code that I'm missing instead of the "shortcut" steps. Any help is appreciated!</p>

<pre><code>    def main():
      while (num &gt;= 100) and (num &lt;= 200):
      for (num % 5 == 0) or (num % 6 == 0)
        print (num)

    main()
</code></pre>

<p>This is how I would go about it. I would recommend using a for loop over a while loop if you know the range you need. You are less likely to get into an endless loop. The reason for the n variable is since you said you needed 10 numbers per line. The n variable will track how many correct numbers you find so that you know when you have ten results and can use a normal print statement which automatically includes a newline. The second print statement will not add a newline.</p>

<pre><code>n = 0
for i in range(100,201):
    if (i%5 == 0 or i%6 == 0) and not (i%5 == 0 and i%6 == 0):
        n += 1
        if n%10 == 0:
            print(i)
        else:            
            print(str(i) + ", ", end="")
</code></pre>

python python-3.x