How to show the output of a ternary operation next to a string, using Python?
I want to check if the size of the name you typed is greater than "Braga". For this condition, I want to use the Python ternary operator to check if it is "larger" or "smaller" and merge this information into the final print string: "Your name is bigger / smaller than mine!".
def operadorTernario():
""" Exemplo do operador ternário """
nome = input('Qual o seu nome? ')
print('O seu nome é', 'maior' if len(nome) > 'Braga' else 'menor', 'que o meu!')
operadorTernario()
To test online, I recommend: Repl.it