Izento Izento - 1 month ago 5x
Python Question

Using len in texts but discluding spaces in the count

So, I am trying to create a program which counts the amount of characters in a string, which is given from the user, but I want to disclude any spaces that the user enters.

def main():
full_name = str(input("Please enter in a full name: ")).split(" ")

for x in full_name:


For this, all I get is the numbers of the characters, without spaces, but I don't know how to add these numbers together and print it.


Count the length and subtract the number of spaces:

>>> full_name = input("Please enter in a full name: ")
Please enter in a full name: john smith
>>> len(full_name) - full_name.count(' ')
>>> len(full_name)