samedi 7 juillet 2018

error with else statement in list comprehension

I was playing around with list comprehension but I get an syntax error with the else statement

doctor = ['house', 'cuddy', 'chase', 'thirteen', 'wilson'] 
first = [doc[0] for doc in doctor if doc[0] == 'h' else doc[3]]

What's the problem with this?

Aucun commentaire:

Enregistrer un commentaire