-3
I need to check if a string has more than 3 characters, how do I do this?
I’ve tried it like this:
nome = input('Digite um nome: ')
a = [i for i in enumerate(nome)]
print([i for i, y in a])
if a > 3:
print('Válido!')
else:
print('Inválido!')
Is making a mistake:
Traceback (most recent call last):
File "/home/hyago/projetos/exerciciosPythonBrasil/EstruturaDeRepeticao/ex3.py", line 4, in <module>
if a > 3:
TypeError: '>' not supported between instances of 'list' and 'int'```
Como resolvo isso?
a
is a list of tuples. You cannot compare this to an integer. To check whether a name has more than 3 characters just dolen(nome)>3
– Lucas
Thank you very much Lucas, it helped me a lot!
– Hyago Santos