-1
missing_buckets = [x in timebuckets if ((x not in found_tenors) and (x == '1y' or x[-1] != 'y'))]

エラーが発生します:

missing_buckets = [x in timebuckets if ((x not in found_tenors) and (x == '1y' or x[-1] != 'y'))]
                                                                                                ^
SyntaxError: invalid syntax
4

2 に答える 2

6
missing_buckets = [x for x in timebuckets if ((x not in found_tenors) and (x == '1y' or  x[-1] != 'y'))]
                   ^^^^^
于 2012-06-21T14:02:09.107 に答える
3

「 for x in 」を忘れました:

missing_buckets = [x for x in timebuckets if ((x not in found_tenors) and (x == '1y' or x[-1] != 'y'))]

于 2012-06-21T14:04:19.213 に答える