[Tutor] Can't be that difficult
Mats Wichmann
mats at wichmann.us
Thu Mar 19 16:52:01 EDT 2020
On 3/19/20 2:17 PM, Curt Hamblin wrote:
> I have two dictionaries:
>
> inv (partNbr(key):qtyOnHand(value), #inventory
>
> need (partNbr(key):qtyNeeded(value) # parts needed for job
>
> the question to answer is : what's in inventory, what has to be ordered
>
> For code :
>
> for partNbr,qtyNeeded in need.items():
>
> print(partNbr, qtyNeeded, inv.get(partNbr,'Not in inventory'))
There's nothing visually wrong with your two-line snip here.
We can't see what else could be wrong, because you only excerpted your
program.
>
>
>
> desired output :
>
> 12345 4 8
>
> 23456 3 2
>
> 34567 2 'Not in Inventory'
>
> this code ALWAYS returns 'Not in Inventory'
>
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
More information about the Tutor
mailing list