Click here to Skip to main content
15,888,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
def chac(a):
if (len(a>1)):
print("enter only one alphabet")
elif a=='a' or a=='e' or a=='i' or a=='o' or a=='u':
print ("its a vowel")
else:
print("its not a vowel")

a=input("enter a single char:")
chac(a)

What I have tried:

getting this error
Traceback (most recent call last):
File "C:/Users/techw/AppData/Local/Programs/Python/Python310/ifelse.py", line 10, in <module>
chac(a)
File "C:/Users/techw/AppData/Local/Programs/Python/Python310/ifelse.py", line 2, in chac
if (len(a>1)):
TypeError: '>' not supported between instances of 'str' and 'int'
Posted
Updated 14-Jul-22 1:59am

1 solution

You have brackets in the wrong place. The line should read
Python
if (len(a)>1):
 
Share this answer
 
Comments
CPallini 14-Jul-22 8:39am    
5.
Tech World Feb2022 14-Jul-22 9:13am    
thanks
CHill60 14-Jul-22 13:51pm    
And my thanks instead of the OP :-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900