Printing a X using * in Python
<p>I have to write a python program which allows a user to input an odd integer, n,  greater than or equal to three.  The program outputs an x with n rows and n columns. *My professor said using nested for loops would be ideal for this. The X is printed using *'s *</p>

<p>I have been experimenting over the past couple days and have had little success.
This is my starting code for the program and after that it's just blank, like my mind. If you could provide some explanation as to how the code works that would be amazing. </p>

<p><code>num=int(input("Please type in an odd integer."))
 if num%2==0:
    print("Your number is incorrect")</code></p>

<p>Using single for loop:</p>

<pre><code>for i in range(num):
    a = [' '] * num
    a[i] = '*'
    a[num-i-1] = '*'
    print(''.join(a))
</code></pre>

<p>Using nested for loops:</p>

<pre><code>for i in range(num):
    s = ''
    for j in range(num):
        if j in [i, num-i-1]:
            s += '*'
        else:
            s += ' '
    print(s)
</code></pre>

python for-loop nested-loops