我正在编写一个程序来做一些统计。我希望输出看起来像
11: 4
22: 3
33: 1
代替
11:4, 22:3, 33:1
因为我觉得很难读。
这是我的代码
#Copy solves here, in seconds, seperated by a comma for each solve
times = [11.9, 14.2, 17.3, 11.2 , 123.4]
#Blank list to copy modified solves into
newtimes = []
for time in times:
#Rounds down every time
time = int(time)
#Adds time to new list
newtimes.append(time)
#Sorts list lowest to highest
newtimes.sort()
#Gets length of new list, which is amount of solves
solves = len(newtimes)
#Set longest and shortest solve times
longestSolve = max(newtimes)
shortestSolve = min(newtimes)
timesfreq = {i:newtimes.count(i) for i in newtimes}
print(newtimes)
print(timesfreq)
print(solves)
print("Your longest solve was " + str(longestSolve) + " seconds and your shortest solve was " + str(shortestSolve) + " seconds")
牛魔王的故事
侃侃尔雅
相关分类