0

I have below block of code in which i have to remove whitespaces from full_name, but am unsuccessful.

name, title = 'Monty', 'Python'
full_name = name + " " + title
print (full_name)
first_name = full_name[-12:-7]
print (first_name)
len_name = str(len(full_name))
len_name.replace(" ","")
print (len_name)
is_f = "f" in full_name
print (is_f)
split = full_name.split()
print (split)
  • duplicate of https://stackoverflow.com/questions/8270092/remove-all-whitespace-in-a-string-in-python – M Waz Jan 09 '20 at 20:48
  • Does this answer your question? [Remove all whitespace in a string in Python](https://stackoverflow.com/questions/8270092/remove-all-whitespace-in-a-string-in-python) – M Waz Jan 09 '20 at 20:48
  • "am unsuccessful" - I mean, your code never tries to remove whitespace from `full_name`, so... – ForceBru Jan 09 '20 at 20:49
  • Need to remove the spaces by Subtracting by 1 – Manoj Gupta Jan 09 '20 at 20:50

1 Answers1

0

Do you want to traverse the string and remove any space you encounter while traversing? The question is not very clear

Shubh9718
  • 63
  • 12