I need to remove spaces from a string in python. For example.
str1 = \"TN 81 NZ 0025\" str1sp = nospace(srt1) print(str1sp) >>>TN81NZ0025
One line of code to remove all extra spaces before, after, and within a sentence:
string = " TN 81 NZ 0025 " string = ''.join(filter(None,string.split(' ')))
Explanation: