dimanche 10 octobre 2021

Lists and loops

I have to be able to calculate the revenu per month depending on the number of goats sold per month knowing that every month I sell 20% of the goats I had initially in January. When I try to calculate it through my price_list I can only get 400$ and not the 300$ for the corresponding months.

The variable d is there to know whether or not the month starts with a vowel. If it does d= "d'" and if not d="de".

I have been going at it for a week and can't seem to find a solution for neither of my two problems.

Help would be really appreciated !!!

goats=int(input("Enter the number of goats at the beginning of january :"))
    
    year= ["january","february","march","april","may","june","july","august","september","october","november","december"]
    vowels = "aeiouy"
    price_list = [400,400,400,400,300,300,300,300,300,300,400,400]
    d=""
        
    if goats >0:
        for month in range(len(year)):
            goats_left = int(goats*0.8)
            goats_sold = goats - goats_left
            goats = goats_left
            print("At the of the month of {0} {1}  , we will have {2} goats left, monthly revenu: {3} $".format(d,year[month],goats,price_list[i]))
    else:
        print("The number entered is not valid {0}.format(goats))
        goats=int(input("Enter the number of goats at the beginning of january :"))
    
    
    
    
    print("\n")
    print("ANNUAL REVENUE ........................................................ :".format())
    print(goats_sold_list)

Aucun commentaire:

Enregistrer un commentaire