op1 if condition else op2
Example
userGender = '0' if userFields[1] == 'M' else '1'
userAge = '0' if userFields[2] == '18-24' else \
'1' if userFields[2] == '25-34' else \
'2' if userFields[2] == '35-49' else '3'
Another interesting way here.
Example
userGender = '0' if userFields[1] == 'M' else '1'
userAge = '0' if userFields[2] == '18-24' else \
'1' if userFields[2] == '25-34' else \
'2' if userFields[2] == '35-49' else '3'
Another interesting way here.
Si le gustó esta entrada, ¡podría invítame a un café!
0 comentarios:
Publicar un comentario