How to calculate string length without spaces in Python

1 Answer

0 votes
s = "Python Programming Language";

# Remove spaces from the string
string_without_spaces = s.replace(" ", "")

length_without_spaces = len(string_without_spaces)

print("Length without spaces:", length_without_spaces)


  
  
'''
run:
  
Length without spaces: 25
  
'''

 



answered Jan 11, 2025 by avibootz

Related questions

1 answer 107 views
1 answer 103 views
1 answer 111 views
1 answer 106 views
1 answer 86 views
1 answer 174 views
1 answer 88 views
...