mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-05 01:09:40 +08:00
Improved readability (#1615)
* improved readability * further readability improvements * removed csv file and added f
This commit is contained in:

committed by
Christian Clauss

parent
938dd0bbb5
commit
9eb50cc223
@ -81,13 +81,13 @@ def knapsack_with_example_solution(W: int, wt: list, val: list):
|
||||
raise ValueError(
|
||||
"The number of weights must be the "
|
||||
"same as the number of values.\nBut "
|
||||
"got {} weights and {} values".format(num_items, len(val))
|
||||
f"got {num_items} weights and {len(val)} values"
|
||||
)
|
||||
for i in range(num_items):
|
||||
if not isinstance(wt[i], int):
|
||||
raise TypeError(
|
||||
"All weights must be integers but "
|
||||
"got weight of type {} at index {}".format(type(wt[i]), i)
|
||||
f"got weight of type {type(wt[i])} at index {i}"
|
||||
)
|
||||
|
||||
optimal_val, dp_table = knapsack(W, wt, val, num_items)
|
||||
|
Reference in New Issue
Block a user