I am trying to create a piece of code that will accept a odd number as a input and create a snowflake using this graph of n * n
Enter Integer: 5
* . * . *
. * * * .
* * * * *
. * * * .
* . * . *
Im pretty sure Im on the the right track
n = int(input("Enter odd input: "))
while n % 2 == 0:
print("Invalid Input. Input must be odd")
n = int(input("Enter odd input: "))
snowflake = [["."] * n for i in range(n)]
middle = int((n-1) / 2)
for i in range(n):
snowflake[i][2] = "*"
snowflake[2][i] = "*"
snowflake[i][i] = "*"
diagnol = 5-i
snowflake[i][diagnol] = "*"
for i in snowflake:
for j in i:
print(j, end=' ')
print()
print()
But I keep getting this error
snowflake[i][diagnol] = "*"
IndexError: list assignment index out of range
Can someone help edit my code or give me a tip?(This is a homework assignment)