“comment trouver la longueur de la chaîne en python sans utiliser Len” Réponses codées

Les acharacters de cordes comptent en python sans utiliser Len

# User inputs the string and it gets stored in variable str
str = input("Enter a string: ")

# counter variable to count the character in a string
counter = 0
for s in str:
      counter = counter+1
print("Length of the input string is:", counter)
Healthy Hummingbird

comment trouver la longueur de la chaîne en python sans utiliser Len

#defining a function to find the length of a string 
def find_length_str(string):
	counter = 0
    if type(string) != str:
        print("Please enter a string...")
    else:
        for s in string:
        	counter += 1
            string += s
        return counter
        
find_length_string('ABCDEFG')
Shaurya Maharishi

Réponses similaires à “comment trouver la longueur de la chaîne en python sans utiliser Len”

Questions similaires à “comment trouver la longueur de la chaîne en python sans utiliser Len”

Plus de réponses similaires à “comment trouver la longueur de la chaîne en python sans utiliser Len” dans Python

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code