Codecademy Help Center

Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

Possible problem with Python 3.5 Paying Up

Leo Bruton-Simmonds Aug 27, 2013 07:39PM EDT

Hi,

Firstly I apologise if I have just not understood something in the exercise. I always post a comment in the forum looking for help first, but it has been up for two days and all I have come across are other people with the same issue.
This is a copy of my thread which can be found here:

http://www.codecademy.com/forum_questions/521b5c18f10c60fb2c001f33
----------------------------------------------------------------------------------------------
This code

def hotel_cost(nights):
return nights * 140

bill = hotel_cost(5)

def add_monthly_interest(balance):
return balance * (1 + (0.15 / 12))

def make_payment(payment , balance):
new_balance = add_monthly_interest(balance-payment)
print "You still owe " + str(new_balance)
return new_balance
first_payment=make_payment(bill/2,bill)
second_payment=make_payment(100,first_payment)

returns to the console:
You still owe 354.375
You still owe 257.5546875
but gives an error message:
Oops, try again! It looks like you didn't print out the correct amount you still owe after paying half your bill in February and another 100 dollars in March! See the hint if you need help!

However this code:

def hotel_cost(nights):
return nights * 140

bill = hotel_cost(5)

def add_monthly_interest(balance):
return balance * (1 + (0.15 / 12))

def make_payment(payment , balance):
new_balance = add_monthly_interest(balance-payment)
return new_balance
first_payment=make_payment(bill/2,bill)
second_payment=make_payment(100,first_payment)
print second_payment

returns to the console:
257.5546875
and passes me!

This seems to run contrary to the instructions which asks me to:
Have the function print the string "You still owe: x", with x being the amount that you still owe.

Is it because it asks me to print the string, rather than the statement that it is right? In any case the answer 257.5546875 is the same in both cases so it seems bizarre to fail students because they print the outcome as a nice statement rather than a bare number.
----------------------------------------------------------------------------------------------------------------------------------------

Just in case you were wondering I also tried it as:

def hotel_cost(nights):
return nights * 140

bill = hotel_cost(5)

def add_monthly_interest(balance):
return balance * (1 + (0.15 / 12))

def make_payment(payment , balance):
new_balance = add_monthly_interest(balance-payment)
return new_balance
first_payment=make_payment(bill/2,bill)
second_payment=make_payment(100,first_payment)
print "you still owe "+str(second_payment)

This is the best option as far as I can see as it simply shows:
you still owe 257.5546875
None
in the console window


Obviously I was able to get through the test and get the console to print the statement 'You still owe 257.5546875' with your error message as above. Is it a bug, or is there something I am not understanding?
I would really appreciate some clarification here, even if just to correct some error on my part. I really want to make sure I get through each section with a full understanding of the method and little quibbles like this really make me unsure of my knowledge and eat up a lot of time in confusion.

Many Thanks,

Leo

p.s. don't take this as a complaint, I really think the site is fabulous. The layout and presentation are attractive and easy to navigate and most importantly the lessons are well-paced, clear, and even funny on occasion! Great stuff.

Up 3 rated Down
Irwen Sep 19, 2013 11:02PM EDT
Strongly agree. Just wondering why only you complained about this issue. I was stuck for quite some time for this issue.
Up 0 rated Down
Henry Sep 20, 2013 04:59AM EDT
I was going to send and email about this but it referred me to this post and I'll just post what I wrote in the email and hope someone from codeacademy reads this and corrects it..

The instructions in this exercise instruct users to make a program that doesn't meet the requirements of the exercise. The line:

'Have the function print the string "You still owe: x", with x being the amount that you still owe.'

Even if the user could create a program that was able to print 'You still owe: x' the exercise only accepts floats as the correct answer. I circumvented the issue because I kept getting an error on labs(which should be recommended for playing with code, I had to use work spaces from other sites or kept going back to a specific part of a lesson to test any code) by leaving out print from the code entirely and just printed the function when I called it.

Knowing this was basically cheating, I went to hints and found nothing of use, and went to the forums as a last resort and found other users with the same issue. I found a post with a proper function saying the the "You still owe: x" was not necessary. I nearly copied it line for line to make the exercise accept the program. I felt a little cheated out of learning because of faulty instruction, or as cheated as I can feel since this is free. But it does cheat users out of properly learning or practicing this code. Please revise the instructions to fit the exercise. Sorry for the long rant. If it even makes sense at this point.
Up -3 rated Down
a9812263 Nov 25, 2013 04:06AM EST
Definitely, I was stuck by this as well. It simply expect us to print the result value while asking us to console the string "You still owe :", which was misleading us.
Up 2 rated Down
philleicht Dec 18, 2013 12:24PM EST
God almighty! I can't thank you enough for making this post and your replies!
I was literally going back and forth in this exercise for about 20 minutes, totally getting frustrated as I thought either my math or my logical understanding is totally borked!

After reading this, I just did as suggested, removed the "politeness" from the output and it let me pass.
That's a really annoying "bug" and should be fixed.

Post Your Public Answer

Your name (required)
Your email address (required)
Answer (required)

Ask a question!

contact@codecademy.com
http://assets03.desk.com/
false
codecademy
Loading
seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
about
false
Invalid characters found
/customer/en/portal/articles/autocomplete