Can someone help me shorten the statements in this code from 18 to 15


#1

can anyone help me shorten the statements in this or simplfy it im currently using 18 statements and need to get it down to 15

def main():
    input_1 = input("Site ID? ")
    input_2 = input("Site name? ")
    input_3 = input("wind Level? ")
    input_4 = input("vehicle counts? ")
    print()
    word = (input_1 + ": " + input_2 + " (Wind=" +(input_3) + ")")
    print(word)
    vehicle_count = input_4.split(" ")
    count_total = len(vehicle_count)
    print("Number of days entered: " + str(count_total))
    numlist = [int(x) for x in vehicle_count]
    sumlist = sum(numlist)
    print("Total vehicles: "+ str(sumlist))
    avglist = sum(numlist) / float(len(numlist)) 
    round(avglist, 1)
    print("Average vehicles/day: " + str(avglist))
    total_count = sum(i > 9999 for i in numlist)
    print("Number of busy days: " + str(total_count))
main()

Please leave the following link in the post so we can find the unit module, else replace it with a link to the exact lesson:

Strings and Console Output


#2

you should answer ionatan in the previous topic, he is right. Its how i got to a single equal sign, using dictionaries.

this code is much vaguer what needs doing, what needs doing? Your teacher really has done a poor job, can’t you ask your fellow classmates?


#3

its okay i solved it sorry


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.