我这里有个密码:
print('Hello Alex! Please tell me how many different shells you collected.')
pukaAlex = int(input('Puka: '))
coneAlex = int(input('Cone: '))
driftwoodAlex = int(input('Driftwood: '))
seaglassAlex = int(input('Sea Glass: '))
starfishAlex = int(input('Starfish: '))
lstAlex = [pukaAlex, coneAlex, driftwoodAlex, seaglassAlex, starfishAlex]
print('Hello Bay! Please tell me how many different shells you collected.')
pukaBay = int(input('Puka: '))
coneBay = int(input('Cone: '))
driftwoodBay = int(input('Driftwood: '))
seaglassBay = int(input('Sea Glass: '))
starfishBay = int(input('Starfish: '))
lstBay = [pukaBay, coneBay, driftwoodBay, seaglassBay, starfishBay]
lstAlexTwo = [('Puka', pukaAlex), ('Cone', coneAlex),
('Driftwood', driftwoodAlex), ('Sea Glass', seaglassAlex),
('Starfish', starfishAlex)]
lstBayTwo = [('Puka', pukaBay), ('Cones', coneBay),
('Driftwood', driftwoodBay), ('Sea Glass', seaglassBay),
('Starfish', starfishBay)]
print('Alex\'s List: ', lstAlexTwo)
print('Bay\'s List: ', lstBayTwo)
我知道我有其他组合列表的选项,但是我不完全确定如何将Alex和Bay列表中的Pukas和cone的数量与for
循环组合起来,从而创建一个新的列表。你知道吗
我知道我可以使用+字符来添加这两个字符
样本输出:
[('Puka', 52), ('Cone', 21)]
假设收集的普卡犬总数为52只,球果为21只。你知道吗
下面是如何组合这些值。然后你可以做你在最后做的事情,把它们和一个新列表中的字符串组合起来。你知道吗
试试这个:
相关问题 更多 >
编程相关推荐