-2

I want to remove space between an integer and a full stop.

sol=(num1+num2)*(num1+num2)
print("\nThe Solution is",sol,'.')

Here output is The Solution is 5 .
I want The solution is 5.
I want to remove space between 5 and fullstop.

khelwood
  • 55,782
  • 14
  • 81
  • 108

3 Answers3

0

This should do it:

    sol=(num1+num2)*(num1+num2) 
    print(f"\nThe Solution is {sol}.")

More about f-strings: https://realpython.com/python-f-strings/#python-f-strings-the-pesky-details

Anuvrat Parashar
  • 2,960
  • 5
  • 28
  • 55
0

You can try with format function In brackets "{}" is a place holder for a value. In format, you specify the value , which is your sol variable

sol=(1+2)*(1+1)

print("\nThe Solution is {}.".format(sol))

Outputs :

The Solution is 6.

Another, shorter version would be using f string. You put f before text string & specify your variable in brackets {}

print(f"\nThe Solution is {sol}.")

Outputs :

The Solution is 6.
Vladyslav Didenko
  • 1,352
  • 1
  • 14
  • 19
-2

Simply change your code to :

sol=(num1+num2)*(num1+num2)
print("\nThe Solution is",str(sol) + '.')
marc
  • 914
  • 6
  • 18