0

here is my code so far

def main():
  dividend = int(input("Please enter an integer for the dividend: "))
  divisor = int(input("Please enter an integer for the divisor: "))
  quotient = dividend//divisor
  remainder = dividend%divisor
  print("The quotient is",quotient, "The remainder is",remainder)


main()

the output is---

Please enter an integer for the dividend:  6
Please enter an integer for the divisor:  5
The quotient is 1 The remainder is 1

However, I need a comma between the two statements so it reads like this

Please enter an integer for the dividend:  6
Please enter an integer for the divisor:  5
The quotient is 1, The remainder is 1

If I do this---

print("The quotient is",quotient,"," "The remainder is",remainder)

I get a space between 1 and the comma like this

The quotient is 1 , The remainder is 1
martineau
  • 119,623
  • 25
  • 170
  • 301
gg81
  • 1
  • 1
    Lots of ways to do it. One way is to use f-strings: `print(f"The quotient is {quotient}, The remainder is {remainder}")` – John Gordon Sep 22 '21 at 18:41
  • Does this answer your question? [How to print without a newline or space](https://stackoverflow.com/questions/493386/how-to-print-without-a-newline-or-space) – Michael T Sep 22 '21 at 18:48

1 Answers1

2

You can use string formatting:

print("The quotient is {}, the remainder is {}".format(quotient, remainder)

Or if you're on python 3.6+, you can use f-strings:

print(f"The quotient is {quotient}, the remainder is {remainder}")
NGilbert
  • 485
  • 6
  • 12
  • The first one worked when I was using an online compiler, but it did not work in the generic python trinket. Thanks for reaching out, I appreciate it. – gg81 Sep 23 '21 at 14:35
  • The string format method was introduced in Python 3.0, so it should work the same in any Python 3 environment. – NGilbert Sep 23 '21 at 14:58