我现在只想输入多组要单独计算的整数。 它会像这样流动。你知道吗
首先一次获取所有用户输入。你知道吗
输入数字1。。。2、4、23、45、57
输入数字2。。。9、23、45、47、33
输入数字3。。。2,41,23,45,55岁
然后输出一次全部打印出来。你知道吗
数字1的序列。。。2,0,1,0,1,1
数字2的序列。。。1,0,1,1,2,0
数字3的顺序。。。1,0,1,0,2,1
这是我的密码。你知道吗
import collections
the_input1 = raw_input("Enter numbers 1... ")
the_input2 = raw_input("Enter numbers 2... ")
the_input3 = raw_input("Enter numbers 3... ")
the_list1 = [int(x) for x in the_input1.strip("[]").split(",")]
the_list2 = [int(x) for x in the_input2.strip("[]").split(",")]
the_list3 = [int(x) for x in the_input3.strip("[]").split(",")]
group_counter = collections.Counter(x//10 for x in the_list1)
group_counter = collections.Counter(x//10 for x in the_list2)
group_counter = collections.Counter(x//10 for x in the_list3)
bin_range = range (6)
for bin_tens in bin_range:
print "There were {} in {} to {}".format(group_counter[bin_tens], bin_tens*10, bin_tens*10+9)
如有任何回应,我们将不胜感激。。谢谢您。。你知道吗
如果我理解正确的话,你需要的频率范围0-9,10-19,…,50-59分别为你的3个输入。我重构了您的程序以实现以下目标:
我用你给定的输入得到了预期的输出。你知道吗
相关问题 更多 >
编程相关推荐