Your function has indents missing in the second while loop to include the if statement. There is also a space missing between the '' when you multiply them.
I also fixed the weird try statement.
Try:
import time, sys
while True:
try:
print("Enter and integer between 5 and 15: ")
userInput = int(input())
if userInput < 5 or userInput > 15:
continue
break
except ValueError:
print("You must enter an integer.")
stars = ''
indent = 0
indentIncreasing = True
try:
stars += "*" * userInput
while True:
print(' ' * indent, end='') # Added a space between the first ''
print(stars)
time.sleep(0.1)
# Indented the following if and else statements
if indentIncreasing:
indent = indent + 1
if indent == 20:
print(' ' * 20 + stars + " START!") # Added a space between the ''
indentIncreasing = False
else:
indent = indent - 1
if indent == 0:
print(stars + " STOP!")
indentIncreasing = True
except KeyboardInterrupt:
sys.exit(
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…