0

I defined a class variable and am attempting to use in within a list comprehension, but the class variable is not defined within the scope of the comprehension.

class Robot:
    turn_radius = 2
    [(i, turn_radius) for i in range(1, 5)]  # turn_radius is not defined

    for i in range(1,5):
        (i, turn_radius)                     # no problems

Could someone explain this to me?

Zhu Weiji
  • 57
  • 8

0 Answers0