python - 使用 Python 2.7,我如何修复此代码,以便程序在工作日将每个结果乘以 64,在周末将每个结果乘以 80?
问题描述
这是我的代码:
days=["Sunday: ", "Monday: ", "Tuesday: ", "Wednesday: ", "Thursday: ", "Friday: ", "Saturday: "] Wdays=["Monday: ", "Tuesday: ", "Wednesday: ", "Thursday: ", "Friday: "] Wends=["Sunday: ", "Saturday: "] demand=[] temp=[] demand=[15, 20, 25, 18, 20, 22, 14] while demand[0]>0 or demand[1]>0 or demand[2]>0 or demand[3]>0 or demand[4]>0 or demand[5]>0 or demand[6]>0: min1=min(demand) ind1=demand.index(min1) temp=demand.copy() temp[ind1]=100000 min2=min(temp) ind2=temp.index(min2) for i in range(7): if i != ind1 and i != ind2: demand[i]-=1 print(demand) for e in range(7): while demand[e]: if Wdays: demand[e]-=1*64 else: demand[e]-=1*80 print(demand[e])`
代码的第二部分似乎有错误:
for e in range(7): while demand[e]: if Wdays: demand[e]-=1*64 else: demand[e]-=1*80 print(demand[e])
但是我找不到它。目标是输出这个,例如:
[15, 19, 24, 17, 19, 21, 14] Weekdays: $6400 Weekends: $2320
它将(1到5)中的数字相加并将它们乘以64,然后将(0和6)中的数字相加并将它们乘以
解决方案
推荐阅读
- angular-universal - window.requestAnimationFrame 不是函数
- java - 无法更新 Maven 配置
- sql - Where execution order on castable int
- php - vtiger 6.4 vtwsclib doInvoke()自定义网络服务不起作用
- python - MLP learning produces bad outcomes for simple cases
- symfony4 - 如何防止“prod”环境显示完整的 symfony4 错误?
- html - 为什么旋转的图像在 css 表中显示不同?
- c# - XmlDocument.Save() 异常 System.ObjectDisposedException:无法访问已关闭的文件
- sql - 将递增值添加到 postgresql 中的列
- xamarin.forms - Set master page full screen on xamarin forms