hey so I am submitting my code through a code homework website my school uses and for some reason it's saying there's something wrong with my spacing on the line with the money amount in it, as you can see in the screenshot below, the output on the left is the expected and the one on the right is what I get. What is wrong with my code that's doing this? Also at the end of each of my outputs it also prints 'None'.? why?
Asked
Active
Viewed 63 times
0
-
`Also at the end of each of my outputs it also prints 'None'.? why?` Can't see that in your attached image, stating the fact that uploading images instead of actual code snippet is not recommended as it makes it hard for the users to understand/debug it. – DirtyBit Mar 15 '19 at 05:41
-
it's a screenshot of the output from a diffchecker website and it shows in red and green the differences, I can't exactly put that here – Amanda_C Mar 15 '19 at 05:44
-
No need to return print when you already are printing in the main calling – DirtyBit Mar 15 '19 at 05:46
-
PS. you do not need all those space acquiring extra lines. – DirtyBit Mar 15 '19 at 05:54
3 Answers
0
One problem is that your thank_donor function returns the print function, and then you call the print function again on THAT. You want the function to return just the plain string which you can then print.

magarnicle
- 186
- 6
0
def thank_donor(first_name, last_name, amount, donor_status):
"""prints thank you note with variables in"""
last = last_name.upper()
first = first_name.capitalize()
return print(
"----------------------------------------" +
"\n" +
"Note to donor:", last + ",", first +
"\n" +
"----------------------------------------" +
"\n" +
"Dear", first + "," +
"\n" +
"Thank you for your donation of", "$" + "{:.2f}".format(amount),
"\n" +
"to our album campaign." +
"\n" +
"This makes you a", donor_status, "member."
"\n" +
"ROCK ON," +
"\n" +
"Blink 992" +
"\n" +
"========================================")
thank_donor("joe", "bloggs", 100, "Bronze")
Try this code. The problem is you are printing none
at the end. This is happening because you are returning a print
function into another print
function i.e. print(print(#something#)
. Just remove anyone of that print
statements.

Andreas
- 2,455
- 10
- 21
- 24
0
def thank_donor(first_name, last_name, amount, donor_status):
"""prints thank you note with variables in"""
last = last_name.upper()
first = first_name.capitalize()
print(
"----------------------------------------" +
"\n" +
"Note to donor:", last + ",", first +
"\n" +
"----------------------------------------" +
"\n" +
"Dear", first + "," +
Here, Don't use the "," at the end of "{:.2f}".format(amount) because that leads to a whitespace, instead use a "+".
"\n" +
"Thank you for your donation of", "$" + "{:.2f}".format(amount) +
"\n" +
"to our album campaign." +
"\n" +
"This makes you a", donor_status, "member."
"\n" +
"ROCK ON," +
"\n" +
"Blink 992" +
"\n" +
"========================================")
Do not use print function multiple times, in the function as well as while calling the function.
thank_donor("joe", "bloggs", 100, "Bronze")

Yash Ghorpade
- 607
- 1
- 7
- 16