python-3.x - 当用户为变量 resp_2 输入 N 或 N 时,从两个循环中跳出
问题描述
当用户输入 resp_2 作为 n 或 n 时使用 break 是否有助于打印两个打印语句并且对于 y 或 Y 循环迭代?
while True:
resp_1=int(input("Select any option from 1-5 : "))
while True:
if True:
if resp_1==1:
#MENSTRUAL CYCLE TRACKER - SHINE
#intro shine
print("SHINE") #BIG SHINE
split_()
print("HI",n_up," I am SHINE\n")
print("I will help you to organise your menstrual cycle\n")
print("No need to feel shy or embarassed")
print("Menstrual cycle is like any other process of our body & its better to know prehand when it occurs!!")
split_()
#user information
print("Please enter the following credentials:!!!!!\n")
print(n_up," When did your last cycle begin?\n")
#date
mon= int(input("MONTH (mm) -- "))
da= int(input("DAY (dd) -- "))
year= int(input("YEAR (yyyy)-- "))
last= int(input("HOW MANY DAYS DOES YOUR NORMAL PERIODS LAST? -- "))
#main
month= {1:"JANUARY",2:"FEBRUARY",3:"MARCH",4:'APRIL',5:'MAY',6:'JUNE',7:'JULY',8:'AUGUST',9:'SEPTEMBER',10:'OCTOBER',11:'NOVEMBER',12:'DECEMBER'}
day= {"JANUARY":30,'FEBRUARY':28,'MARCH':31,'APRIL':30,'MAY':31,'JUNE':30,'JULY':31,'AUGUST':31,'SEPTEMBER':30,'OCTOBER':31,"NOVEMBER":30,'DECEMBER':31}
#leap year check for february
if year%4==0:
if mon==2:
mtch=month.get(mon)
day1=29
else:
mtch=month.get(mon)
day1=day.get(mtch)
else:
mtch=month.get(mon)
day1=day.get(mtch)
#formulae & logic
n=(da+28+last)
#specify result
if day1==30 or 31 or 29 or 28:
v=mon+1
next_mon= month.get(v)
nxt_day1=day.get(next_mon)
next_day=n-nxt_day1
print("\nNEXT CYCLE STARTS ON:",next_mon,next_day,year)
elif n<30:
mtch=month.get(mon)
print("NEXT CYCLE STARTS ON:",mtch,n,year)
#keep at last
resp_2=input("Do you want to continue? (Y/N) -- ")
if resp_2 == 'Y' or 'y':
True
elif resp_2 == 'n' or 'N':
break
print("THANK YOU",n_up,"DO COME BACK SOON")
print("HASTA LA VISTA!!!!!!")
解决方案
推荐阅读
- vba - 将演示文稿与 ActivePresentation.Slides.InsertFromFile 结合时,Mac 上的 VBA Powerpoint 错误
- python - 在python中按日期对类实例列表进行排序
- arrays - VBA EXCEL宏代码执行中断使用列重新排序数组
- plot - Octave 绘图中 datetick 函数的意外行为
- c++ - CLion 的“运行”按钮灰显或无法正常工作
- python - 谷歌云中的Django部署错误(pywin32问题)
- javascript - 我做了一个计算器,但我不知道如何显示计算器是如何计算的
- java - 如何实时查看 ProgressMonitor 进度?
- ag-grid - 如何使用服务器端数据源设置起始页
- php - 如何从动态链接中提取 m3u8?