Outside of a for-loop, x in range(..)
mean something different. It's a test that returns a boolean
print(1 in range(1,11)) # prints True
So your while-loop actually means this:
def main():
x=1;
while True if x in range(1,11) else False:
print (str(x)+" cm");
if __name__=="__main__":
main();