Min/Max function
Made a new function that finds the minimum and maximum of the data.
How it works
- The program asks the user to type 0 or 1 for min/max
- The program uses a for loop and goes through each row finding the maximum and minimum or what the user chose.
- In each cell in the sheet, the program checks if that cell is less/greater than the current min/max using the min()/max() function.
- The function then returns a tuple of the price of the product that was the min/max and the name of that product.
- The result is printed using a formatted string.
Debugging
While creating the function, there was some errors with the if statement.
-
The if statement checks if the user typed 0 or 1, but the user input was not converted into an int. So the min max function was skipped.
-
The function started to return the minimum price but the name of that product was different.
-
The fix was simple - there was an if statement that checked if the min/max was the current cell but the part where it assigns the product_name was not indented, so it was out of this if statement
-
Had a few errors with unpacking, but the changes were made to fix it
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.