除了一件事,一切都对我有用。我需要我的输出将名称和值分组在print(names, "\n" values)
部分中。
例如:Pat : €99, Kev : €55, Dermot : €100
。
我的代码如下:
salesperson = int(input("How many salesperson's do you wish to account
for:"))
names = []
values = []
counter = 0
total_sales = 0
total_value = 0
if salesperson > counter:
while salesperson != counter:
name = input("Please enter in the salesperson's name:")
value = float(input("Please enter in the value of sales for the
salesperson:"))
salesperson -= 1
names.append(name)
values.append(value)
total_value += value
from statistics import mean
average_values = mean(values)
minimum = min(values)
maximum = max(values)
print(names,"\n",values)
print(average_values)
print(total_value)
print(minimum)
print(maximum)
最佳答案
print([f"{x}: £{y}" for x, y in zip(names,values)])
输出:
['Pat: £1.0', 'Dermot: £2.0', 'Kev: £3.0', 'Boris: £4.0', 'Jeremy: £5.0']
关于python - 打印两个列表中的值对,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/59268711/