0

How to fix this problem , object of type 'type', has no len()

string = input("Enter a string :") vowel = 0 digit = 0 consonant = 0 specialchar = 0 for i in range(0,len(str)): ch = str[i] if ch >= 'a' and ch <= 'z' or ch >= 'A' and ch <= 'Z': ch = ch.lower() if ch == 'a' or ch == 'e' or ch == 'i' or ch == 'o' or ch == 'u': vowel +=1 else: consonant +=1 elif ch >= '0' and ch <= '9': digit +=1 else: specialchar +=1 print("vowels : ",vowel) print("consonant : ",consonant) print("digit : ",digit) print("specialchar : ",specialchar)

13th Feb 2021, 12:15 PM
Marlou Abing Edem
Marlou Abing Edem - avatar
2 Answers
+ 3
In line "for i in range(0, len(str)) :" str is a type and len function don't know how to deal with them, maybe you meant to use string .
13th Feb 2021, 12:19 PM
Abhay
Abhay - avatar
+ 1
Abhay thnx
13th Feb 2021, 12:21 PM
Marlou Abing Edem
Marlou Abing Edem - avatar