I've read through a number of the python whitespace removal questions and answers but haven't been able to find what I'm looking for. Here is a small program that shows a specific example of the issue. I greatly appreciate your help.
import random
math_score = random.randint(200,800)
math_guess = int(input("\n\nWhat score do you think you earned on the math section (200 to 800)?\t"))
print ("\n\n\nOn the math section, you guessed",math_guess,", and your actual score was",math_score,"!")
So here's my issue:
When I execute the program, I get the following results:
On the math section, you guessed 600 , and your actual score was 717 !
I would like to remove the space that follows each variable in the sentence. In this case the space between 600 and the "," and the space between 717 and the "!".
Is there a standard way to approach this issue?
You need to format the entire line into a single string, then print that string.
Try this one:
You can read more at Built-in Types
Yes, format your string:
if this is py3+ i think
should work if not
or use string formatting as others have suggested...