9/13, I know for a fact this is wrong, but code says it's correct and lets me move on LOL


#1
> prices = {
>   "banana" : 4,
>   "apple"  : 2,
>   "orange" : 1.5,
>   "pear"   : 3,
> }
> stock = {
>   "banana" : 6,
>   "apple"  : 0,
>   "orange" : 32,
>   "pear"   : 15,
> }
> 
> for key in prices:
>   print key
>   print "price: %s" % prices[key]
>   print "stock: %s" % stock[key]
>   
> total = 0
> 
> for product in prices:
>   prices = product * stock[product]
>   print prices
 
print total

Console gives some crazy stuff, however there is no error. Somehow it says that my code is correct…


#2

Remember, product is a subscript (a key), not a value.


#3

Yeah I fixed the code, I just posted this because I was confused why the thing accepted code that was completely wrong lol…


#4

The SCT is not exhaustive and quite often just check for the presence of certain keywords or patterns, not whether the code actually works… The reverse is sometimes the case. Code works fine and is valid, yet the SCT will reject it because it does not see what is expected.


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.