So wie dieser es zu bekommen ich versuche, in Python 3 zu sehen:Translating eine Liste von Zahlen zu einem Grafikformat (#)
How many hours are in your sample? 7
Enter the count of cars for hour #1: 2
Enter the count of cars for hour #2: 5
Enter the count of cars for hour #3: 9
Enter the count of cars for hour #4: 11
Enter the count of cars for hour #5: 12
Enter the count of cars for hour #6: 6
Enter the count of cars for hour #7: 5
Hour #1: # #
Hour #2: # # # # #
Hour #3: # # # # # # # # #
Hour #4: # # # # # # # # # # #
Hour #5: # # # # # # # # # # # #
Hour #6: # # # # # #
Hour #7: # # # # #
Average: # # # # # # #
Und ich geschrieben habe dies bisher:
def main():
hourlist = number_cars()
graphic = hourlist
car_count_graphic_format(graphic)
def number_cars():
hours = input("How many hours are in your sample? ")
hours = int(hours)
hourlist = []
for i in range(hours):
hourcount = input("Enter the count of cars for hour #" +str(i+1)+ ": ")
hourcount = int(hourcount)
hourlist.append(hourcount)
hourlist.sort()
return hourlist
def car_average(car_count):
car_sum = 0
for position in range(len(car_count)):
car_sum = car_sum + car_count[position]
average = car_sum/len(car_count)
return average
def car_count_graphic_format(graphic):
for x in range(graphic):
graphic = "#" * graphic
print("Hour #:" ,graphic,)
main()
Aber wenn ich es laufen lasse, hat es einen Fehler und ich bin ehrlich gesagt an diesem Punkt fest, was zu tun ist. Wenn mir jemand dabei helfen könnte, würde ich das sehr schätzen! Danke für alle, die mir dabei helfen können!
Was ist der Fehler, den Sie sehen? – poke
Bitte lösche keine Fragen, nachdem du eine Antwort erhalten hast. – MattDMo
Bitte lösche keine Fragen, nachdem sie gelöst wurden, sondern [akzeptiere eine Antwort] (http://meta.stackexchange.com/a/5235/141542). Das Löschen eigener Fragen tut nur weh, und die Fragen waren nicht einmal schlecht, also gibt es wirklich keinen Grund, sie zu löschen. – poke