I'll try to make it clearer with an example code:
def is_opposite(string_1, string_2):
if string_1.lower() == string_2.lower():
if len(string_1) == # some value:
return # do smth
elif len(string_2) == # some value:
return # do smth
return # do smth
There's a main if string_1.lower() == string_2.lower(): condition that prevents a nested block of code to run when False. So how can that code be written in a single return ... line? If can.
Thank you.
Aucun commentaire:
Enregistrer un commentaire