lundi 18 mai 2020

OSRS Fishing Calculator "if...elif" block repeats results per item in list

Creating a Fishing calculator where it can **Be able to type in how many fish caught, which fish was caught, and show the graph of XP gained with the total amount of fish in related to each fish.

First, graph the fish. Second, determine which fish was caught then how many were caught. Third, calculate total XP.

Print the plot/graph.**

if __name__ == '__main__':
    try:    
        fish_menu()
        types_of_fish = int(input('How many kinds of fish did you catch?: '))
        fishes = []
        caught = []
        if types_of_fish < 6:
            for i in range(1, types_of_fish+1): 
                which_fish = input('What was fish number {0}: '.format(i))
                catch = int(input('How many did you catch of {0}: '.format(which_fish)))
            #Adding the fish type and total amount into the empty lists
                fishes.append(which_fish)
                caught.append(catch)
                print()
            #We are able to at least have the first fish entry be calculated
            for i in range(types_of_fish):
                for f in fishes:
                    fish_calc()
                    print()

The result I keep getting most of the time is that it will repeat the top "if" statement for both numbers inputted for

catch = int(input('How many did you catch of {0}: '.format(which_fish)))

For example, if I catch 2 types of fish, the first being "Tuna" at 12 pieces and the second "Lobster" at 14 pieces this is what I receive:

How many kinds of fish did you catch?: 2
What was fish number 1: Tuna
How many did you catch of Tuna: 12

What was fish number 2: Lobster
How many did you catch of Lobster: 14

Catching 12 Tuna is 1200 total fishing XP

Catching 12 Tuna is 1200 total fishing XP

Catching 14 Tuna is 1400 total fishing XP

Catching 14 Tuna is 1400 total fishing XP

I don't know if I should change the function I created; fish_calc().

def fish_calc():
    if 'Tuna' in fishes:
        print('Catching {0} Tuna is {1} total fishing XP'.format(caught[i], caught[i]*100)) 
    elif 'Lobster' in fishes:
        print('Catching {0} Lobster is {1} total fishing XP'.format(caught[i], caught[i]*120)) 
    elif 'Swordfish' in fishes:
        print('Catching {0} Swordfish is {1} total fishing XP'.format(caught[i], caught[i]*140)) 
    elif 'Monkfish' in fishes:  
        print('Catching {0} Monkfish is {1} total fishing XP'.format(caught[i], caught[i]*150)) 
    elif 'Shark' in fishes:
        print('Catching {0} Shark is {1} total fishing XP'.format(caught[i], caught[i]*210)) 

Aucun commentaire:

Enregistrer un commentaire