0

I keep getting warnings in PyCharm saying "Shadows name from outer scope" and I keep trying to clean it up so that the warning disappears. No matter what I do, I can't seem to figure out how to get rid of the warning.

Here's one example:

def move_rooms(room, direction):
new_room = room
for i in rooms:
    if i == room:
        if direction in rooms[i]:
            new_room = rooms[i][direction]
return new_room

Here are the warnings I'm getting:

  • Shadows name 'direction' from outer scope: 1

  • Shadows name 'new_room' from outer scope: 2

  • Shadows name 'new_room' from outer scope: 6

I'm fairly new to using PyCharm, I thought that the code looked fine. What should I do differently to clean this up?

marcocunha
  • 11
  • 2

1 Answers1

0

You're using same names as you have as a global or outside of the function. Either tell python they're global (global var_name) or be more creative. :^) Otherwise it's confused what you mean.

VeeKoo
  • 36
  • 3