Cannot break out of while loop in python
问题 Cannot break out of while loop in python: I tried merging the code all together with no main and getheight functions, and it still gives me an infinite loop. def main(): x = 0 while x not in range (1,23): getheight() if x in range (1,23): break for i in range (x): for j in range (x - j): print (" ", end="") for j in range (x): print ("#", end="") print (" ", end="") for j in range (x): print ("#", end="") "\n" def getheight(): x = input("Give me a positive integer no more than 23 \n") return