lundi 25 mai 2020

IF statement and return python

I am trying to design a function that returns whether a or b is longer but I'm having a syntax error.


def get_longer(a:str, b:str):

    return a if len(a) >= len(b) else return b 

I have tried with a print statement and it is working however I need it to work with a return statement.

Any suggestions?

Aucun commentaire:

Enregistrer un commentaire