while循环
1.while循环
user_answer_correct = False
while not user_answer_correct:
user_gender = input("请输入您的性别(F/M):")
if user_gender == 'F':
print("你是萌妹子")
user_answer_correct = True
elif user_gender == 'M':
print("你是糙汉子")
user_answer_correct = True
else:
print("输入不正确,请输入F或M")
while循环:当满足条件时一直执行里面的代码块
i = 1
while i < 10:
print(i)
i = i +1
2.跳出循环------continue
i = 1
while i < 10:
i += 1
if i%2 > 0:
continue
print(i)
3.跳出循环------break
i = 1
while True:
print(i)
i += 1
if i > 10:
break