title: Python Generator object at location print statement when trying to remove repeats from the list
body: <p>I am working on a text-based adventure game for my course and I am having a really difficult time removing repeated items from a list. I am getting print lines that say <code>[&lt;generator object &lt;genexpr&gt; at 0x000001DF76F37510&gt;] </code>. I am not sure what I did, just that it in line 93. I am just now learning python and I'm only in week 8 so please be aware that I am still learning terminology. Here is my code:</p>
  <pre><code>import time
  from typing import Set, Union
  
  delay = 0.5
  
  # evaluation strategy, call by object sharing. modify list w/room. to append items to bag.
  def item(b_list):
     l = b_list.append(items_bag[current_location])
     print(&quot;Your Bag: {}&quot;.format(l))
  
  # Function to output welcome message prompt and collect user name.
  def welcome_message(player_name):
     message = &quot;Hi {}, Welcome to Escape the Children. This is a text-based\n&quot; \
                       &quot;adventure game. You must successfully navigate through the home,\n&quot; \
                       &quot;without encountering the children. If the children see you its game over.\n&quot; \
                       &quot;In order to win, you must make it back to the front door, with all six items.&quot;.format(player_name)
     print(message)
  
  # Function to output game instructions
  def game_instructions(player_name):
     instructions = &quot;In order to move through the rooms of the home, type in chosen\n&quot; \
                         &quot;direction. You can choose to go north (n), south (s), east (e), west (w).\n&quot; \
                         &quot;{}, enter quit (q) at any time to exit the game.\n&quot;.format(player_name)
     print(instructions)
  
  
  
  # This dict gives each room a string, that informs user of room. I used integers for readability
  player_location = {0: &quot;You are at the front Door.&quot;,
                     1: &quot;You are in the Living Room.&quot;,
                     2: &quot;You are in the Bathroom.&quot;,
                     3: &quot;You are in the Kitchen.&quot;,
                     4: &quot;The children have you spotted you in the Dining Room. \nGAME OVER!&quot;,
                     5: &quot;You are in the Master Bedroom.&quot;,
                     6: &quot;You are in the Playroom.&quot;,
                     7: &quot;You are in the Mudroom.&quot;,
                     8: &quot;You are in the Second Bedroom.&quot;,
                     9: &quot;You have Quit the game. See you next time.&quot;}
  
  #This dictionary links each room (using a number) to original location and available directions and links to next room
  rooms = {0: {&quot;N&quot;: 1, &quot;S&quot;: 2, &quot;W&quot;: 5, &quot;E&quot;:7, &quot;Q&quot;: 9},
           1: {&quot;N&quot;: 3, &quot;S&quot;: 0, &quot;Q&quot;: 9},
           2: {&quot;N&quot;:0, &quot;S&quot;: 4, &quot;Q&quot;: 9},
           3: {&quot;S&quot;: 1, &quot;Q&quot;: 9},
           4: {&quot;I'm Sorry! \n&quot;: 4},
           5: {&quot;E&quot;: 0, &quot;W&quot;:6, &quot;Q&quot;: 9},
           6: {&quot;E&quot;: 5, &quot;Q&quot;: 9},
           7: {&quot;W&quot;: 0, &quot;E&quot;: 8, &quot;Q&quot;: 9},
           8: {&quot;W&quot;: 7, &quot;Q&quot;: 9},
           9: {&quot;Q&quot;: 9} }
  
  # dict of vocabulary player can enter, into game.
  vocab = {&quot;QUIT&quot;:  &quot;Q&quot;,
           &quot;NORTH&quot;: &quot;N&quot;,
           &quot;SOUTH&quot;: &quot;S&quot;,
           &quot;EAST&quot;:  &quot;E&quot;,
           &quot;WEST&quot;:  &quot;W&quot;}
  # dict of bag items
  items_bag = {0: &quot;&quot;,
                1: &quot;Keys&quot;,
                2: &quot;Wallet&quot;,
                3: &quot;Phone&quot;,
                4: &quot;&quot;,
                5: &quot;Glasses&quot;,
                6: &quot;Laptop&quot;,
                7: &quot;Coffee&quot;,
                8: &quot;&quot;,
                9: &quot;&quot;}
  
  #list of bag items
  test_bag = [&quot;Keys&quot;, &quot;Wallet&quot;, &quot;Phone&quot;, &quot;Glasses&quot;, &quot;Laptop&quot;, &quot;Coffee&quot;]
  
  
  
  # collect user data
  name = input(&quot;Enter your name: &quot;).capitalize()
  welcome_message(name)
  time.sleep(delay)
  print(&quot;~&quot; * 40)
  time.sleep(delay)
  game_instructions(name)
  print(&quot;~&quot; * 40)
  b = []
  
  current_location = 0
  while True:
     # Joins the room dict keys and concatenates a string to loop through the available_exits and add direction and a &quot;'&quot;.
     available_exits = &quot;, &quot;.join(rooms[current_location].keys())
     time.sleep(delay)
     print(player_location[current_location]) # Calls the current location key's value, from the locations.
     # add items to the bag using the location as the key, calling th value of same key in items dict. sent to list
     # also removes duplicates from the list
     b.append(items_bag[current_location] for x in test_bag if x not in b )
  
  
  
     # print(&quot;You have added the following items in your bag: {}&quot;.format(b))
     print(&quot;You have the following items in your bag: {}&quot;.format(b))
  
  
  
     # If the current_location is 4 (Dining room w/ villains) terminate loop.
  # If current location is 9 (Quit game) terminate loop.
     if current_location == 4:
        break
     if current_location == 9:
        break
  
  # Prompt player to input desired direction into game. Provide player with available_exits (line 37). Force upper-case.
     direction = input(&quot;Available directions are: &quot; + available_exits + &quot; \n&quot;).upper()
     time.delay = 1
  
  # if the player input is longer than 1 character, split it into a list. Then parse list through vocab dict. For speed.
     if len(direction) &gt; 1:
        words = direction.split()
        for word in words:
           if word in vocab:
              direction = vocab[word]
              break
  # if the players chosen direction is in the rooms dict it will print out the room dicts key, value along with
  # providing the player wit ha prompt to chose another direction and allowing input.
     if direction in rooms[current_location]:
        current_location = rooms[current_location][direction]
  
     else:
        print(&quot;Choose a valid direction&quot;)
  </code></pre>
  <p>is there a better way to do this:
  <a href="https://i.stack.imgur.com/eEjyL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eEjyL.png" alt="enter image description here" /></a></p>