Write a Python program to remove spaces from a given string


The program is written in Python and it performs the following operations:

  • In the first line, a string "Tutor Joes Computer Education" is assigned to the variable "str1".
  • In the second line, the print function is used to print the value of "str1", which is "Tutor Joes Computer Education".
  • In the third line, the "replace" method of the string object is called on "str1" and it replaces all the spaces in the string with empty spaces. The result of this operation is stored back in the "str1" variable.
  • In the fourth line, the print function is used to print the value of "str1", which is now "TutorJoesComputerEducation".
  • The last line of the code is incomplete and doesn't make sense. It appears to be trying to call the "add" method on an object "t", but it's not clear what this object is supposed to be, and this line of code would result in an error.

Source Code

str1 = "Tutor Joes Computer Education"
print(str1)
str1 = str1.replace(' ','')
print(str1)

Output

Tutor Joes Computer Education
TutorJoesComputerEducation


Example Programs