Reputation: 23
def print_scores(name1, score1, name2, score2):
print("\n--- SCORES\t"+ name1 + ":",score1,"\t" + name2 + ":",score2, "---")
print_scores("Ziggy",18,"Elmer",23)
I am trying to remove the space between score1 and "\t". It does not change the output. But the program checking the work requires that there is no space between them in the code.
Upvotes: 2
Views: 114
Reputation: 2878
Since this is Python 3.7, this would work and will be the easiest way to format:
def print_scores(name1, score1, name2, score2):
print(f"\n--- SCORES\t{name1}:{score1}\t{name2}:{score2}---")
print_scores("Ziggy", 18, "Elmer", 23)
Upvotes: 2
Reputation: 4197
Try using format
, like this:
print('\n--- SCORES\t{}:{}\t{}:{}---'.format(name1, score1, name2, score2))
Now for print_scores("Ziggy",18,"Elmer",23)
, it prints this:
--- SCORES Ziggy:18 Elmer:23---
Upvotes: 4
Reputation: 132
This is a problem with the print builtin function.
By default it sets a keyword sep = ' '
This can be overridden by the use of:
print(..., sep='')
Hope that helps.
Upvotes: 5