This is my code, I am trying to add recursion so when the user inputs a number less than 0, it will not only say Invalid Entry, but it will also bring up the original prompt for them to try another number. I am also trying to change my for loop into a while loop. Any help?
space = '\t'
star = '*'
size = int(input("Enter the height of the pattern (must be greater than 0): "))
if size <= 0 :
print("Invalid Entry!\n")
for i in range(0, size) :
star_count = 2 * i - 1
line = space * (size - i - 1)
if i == 0 :
line += "1"
else :
line += str(2 * i) + space
line += (star + space) * star_count
if i > 0 :
line += str(2 * i + 1)
print(line)
The output should look like this
1
2 * 3
4 * * * 5
6 * * * * * 7
8 * * * * * * * 9