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 126 views
1 answer 118 views
1 answer 123 views
1 answer 124 views
1 answer 98 views
1 answer 190 views
1 answer 105 views
...