もとのコードが
pyhon
1def_init_( 2 obstacle_center_x=3.00,obstacle_center_y=3.00 3 with_obstacle = True) 4 5 self.obstacle_center_x = obstacle_center_x 6 self.obstacle%center_y = obstacle_center_y 7```というもので、この外にほかのコードがあり、それによりcenter位置を設定するのみでobstacleが生成されます。 8このobstacleを増やしたいため 9```python 10def_init_( 11 obstacle0_center_x=8.00, obstacle0_center_y=0, 12 obstacle1_center_x=8.00, obstacle1_center_y=-0.06, 13 obstacle2_center_x=8.00, obstacle2_center_y=-0.12, 14 obstacle3_center_x=8.00, obstacle3_center_y=-0.18, 15 with_obstacle0 = True,with_obstacle4 = True, 16 with_obstacle2 = True,with_obstacle3 = True) 17 18 for i in range (3) 19 self.obstacle%d_center_x %(i) = obstacle%d_center_x %(i) 20 self.obstacle%d_center_y %(i) = obstacle%d_center_y %(i) 21
と書いたのですが
SyntaxError: can't assign to operator
とされ実行できませんでした。
ちなみに
python
1def_init_( 2 obstacle0_center_x=8.00, obstacle0_center_y=0, 3 obstacle1_center_x=8.00, obstacle1_center_y=-0.06, 4 with_obstacle0 = True, with_obstacle1 = True) 5 6 self.obstacle0_center_x = obstacle0_center_x 7 self.obstacl0_center_y = obstacle0_center_y 8 self.obstacle1_center_x = obstacle1_center_x 9 self.obstacl1_center_y = obstacle1_center_y
とした場合はうまくいきました。
回答1件
あなたの回答
tips
プレビュー