IF 语句无效语法消息

heyzi1992

如何更改 IF 语句?我只得到无效的语法

predicted_sentiment = [if score < 0 then 'Negative', if score == 0 then 'Neutral' if score > 0 then 'Positive' for score in sentiment_polarity] 
内德·巴切尔德

你可能想要:

predicted_sentiment = [
    ('Negative' if score < 0 else 'Neutral' if score == 0 else 'Positive') 
    for score in sentiment_polarity
]

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章