0
Help
what is wrong with my code????? try: name = input() n = 0 for i in name: n+=1 if n < 3 or n < 4: except: print('Invalid Name') else: print('Account Created') plz help
3 Answers
+ 1
if n < 3 or n < 4:
( n < 4) will never be True without (n < 3) also being True, so this is weird.
if you're wanting to trigger an exception on the if case, you want to "raise" the desired exception and put your except block at the end to catch it.
+ 1
Use raise to create exception.
n<4 is Logical Because it also includes n<3
name = input()
n = 0
for i in name:
n+=1
if n < 4:
raise Exception('Invalid Name')
else:
print('Account Created')
0
You put the try and except in strange places. I would not use then at all.