while语句:
count = 0while True: print(count) count += 1 if count == 10: break
实例:
计算n!,若:n = 5;则:n! = 5 * 4 * 3 * 2 * 1
#n!n = int(input("输入n:"))number = nwhile True: if number == 1: break number = number * (n-1) n -= 1 if n <= 2: breakprint(number)