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.
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.
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
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.
Simply change your code to :
sol=(num1+num2)*(num1+num2)
print("\nThe Solution is",str(sol) + '.')