
#!/usr/bin/env python
# getting user input
height = int(raw_input("height: "))
while (height < 0 or height > 23):
height = int(raw_input("height: "))
# building the "pyramid"
spaceCount = height
hashCount = 1
for i in range(height):
assert height != 0
hashCount += 1
spaceCount -= 1
print " " * spaceCount,
print "#" * hashCount
The code should keep prompting user if input is not an integer. But how?