Hello there everyone i hope you are all doing fantastic. Im currently working on a little program that is designed to do a basic function to help me to trade efficiently within the game Star Citizen:
#1 take two inputs ( location and destination ) #2 Find what product is best to buy at location to sell at destination #3 Print the results currently i have figured out how to get python to take the two inputs and provide me with the lowest buy price and highest sell price. However the information i want to produce is what has the largest profit margin possible between the two locations so i need to compare what items are available in both locations and then see what one has the largest price difference then display that items name. Below is the code i have currently made for this. Current_Location = input("Where are you currently located? :").lower() Current_Destination = input("Where are you planning to travel? :").lower() def Find_Lowest_Buy_Olisar(): print("Finding lowest buy price for OLISAR...") print(*Sort_Buying_Olisar[:1], sep='\n') def Find_Highest_Sell_Olisar(): print("Finding highest sell price for OLISAR...") print(*Sort_Selling_Olisar[:1], sep='\n') def Find_Lowest_Buy_Levski(): print("Finding lowest buy price for LEVSKI...") print(*Sort_Buying_Levski[:1], sep='\n') def Find_Highest_Sell_Levski(): print("Finding highest sell price for LEVSKI...") print(*Sort_Selling_Levski[:1], sep='\n') Buying_Olisar = [('Medical Supply', 17.01), ('Waste', 0.005),] Sort_Buying_Olisar = sorted_by_second = sorted(Buying_Olisar, key=lambda tup: tup[1]) Selling_Olisar = [('Agricium', 25.60), ('Aluminum', 1.25), ('Beryl', 4.26), ('Chlorine', 1.57), ('Corundum', 2.53), ('Diamond', 6.90), ('Distilled Spirits', 4.95), ('Fluorine', 2.80), ('Gold', 6.07), ('Hydrogen', 1.02), ('Iodine', 0.41), ('Laranite', 28.91), ('Processed Food', 1.39), ('Quartz', 1.44), ('Scrap', 1.67), ('Stims', 3.40), ('Titanium', 8.27), ('Tungsten', 3.90),] Sort_Selling_Olisar = sorted(Selling_Olisar, key=lambda tup:(-tup[1], tup[0])) Buying_Levski = [('Agricultural Supply', 1.11), ('Aluminum', 1.20), ('Hydrogen', 0.98), ('Iodine', 0.38), ('Quartz', 1.37), ('Waste', 0.005),] Sort_Buying_Levski = sorted_by_second = sorted(Buying_Levski, key=lambda tup: tup[1]) Selling_Levski = [('Agricium', 25.60), ('Altruciatoxine', 11.63), ('Beryl', 4.25), ('Chlorine', 1.56), ('Corundum', 2.53), ('Diamond', 6.07), ('Distilled Spirits', 4.95), ('Fluorine', 2.80), ('Gold', 6.07), ('Laranite', 28.25), ('Medical Supply', 18.00), ('Processed Food', 1.38), ('Scrap', 1.68), ('Stims', 3.40), ('Titanium', 8.27), ('Tungsten', 3.90), ('Widdow', 24.00),] Sort_Selling_Levski = sorted(Selling_Levski, key=lambda tup:(-tup[1], tup[0])) if Current_Location == "olisar": Find_Lowest_Buy_Olisar() elif Current_Location == "levski": Find_Lowest_Buy_Levski() else: print("Unknown location please try again.") if Current_Destination == "olisar": Find_Highest_Sell_Olisar() elif Current_Destination == "levski": Find_Highest_Sell_Levski() else: print("Unknown location please try again.") Any input would be hugely appreciated. Kind regards, Harry O'Neill _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor