1. 程式人生 > >笨辦法33while循環

笨辦法33while循環

pri real put 重新 span bsp blog while post

改了之前的代碼,加入while:

 1 #coding: utf-8
 2 print("王小狗醜不醜?醜→1;不醜→2")
 3 answer = input(">")
 4 if answer == "1":
 5     print("恭喜你,你的選擇很正確!")
 6 
 7 elif answer == "2":
 8     print("要不,你再考慮一下? ")
 9     print("王小狗究竟醜不醜?醜→1;不醜→2")
10     real_answer = input(">")
11     while real_answer != "1" and real_answer != "
2" : 12 print("別搗亂!王小狗醜不醜?醜→1;不醜→2") 13 real_answer = input(">") 14 while real_answer == "2" or real_answer != "1": 15 print("我覺得差不多了,你就說王小狗到底醜不醜?醜→1;不醜→2") 16 real_answer = input(">") 17 if real_answer == "2": 18 print("說這種話,你自己信嗎!") 19 elif
real_answer == "1": 20 pass 21 else: 22 print("請你認真回答。") 23 print("恭喜你,可以去睡覺了!") 24 25 else: 26 print("不好好做題,你想作甚王小醜!") 27 print("請重新回答,王小狗醜不醜?醜→1;不醜→2") 28 last_answer = input(">") 29 while last_answer != "1" and last_answer != "2": 30 print
("快回答!王小狗醜不醜?醜→1;不醜→2") 31 last_answer = input(">") 32 while last_answer == "2" or last_answer != "1": 33 print("無論如何,王小狗醜不醜?醜→1;不醜→2") 34 last_answer = input(">") 35 if last_answer == "2": 36 print("不能因為你的善良而埋沒了良知!") 37 elif last_answer == "1": 38 pass 39 else: 40 print("你踏馬好好回答行不行?") 41 print("恭喜你,可以去睡覺了!") 42 43 input()

笨辦法33while循環