Übertragung von Gegenständen von einem Wörterbuch auf ein anderes übertragenPython

Python-Programme
Anonymous
 Übertragung von Gegenständen von einem Wörterbuch auf ein anderes übertragen

Post by Anonymous »

Ich arbeite an einer College -Aufgabe und muss herausfinden, wie ein Element von einem Wörterbuch (Element) auf ein anderes (Inventar) übertragen werden kann. Dies muss durchgeführt werden, indem ein Element in einem Raum mit der Funktion search_for_items verwendet wird. Hier ist der Code, den ich bisher habe: < /p>

Code: Select all

rooms = {
'Main Entry': {'East': 'Main Floor'},
'Main Floor': {'North': 'North Hall', 'South': 'South Hall', 'East': 'Clothes Store', 'West': 'Main Entry'},
'South Hall': {'East': 'Food Court', 'North': 'Main Floor'},
'North Hall': {'East': 'Storage Room', 'South': 'Main Floor'},
'Clothes Store': {'North': 'Theater', 'West': 'Main Floor'},
'Theater': {'South': 'Clothes Store'}
}

item = {
'Gas Mask',
'Stuffed Shark',
'Bubble Wrap',
'Knowledge of Toaster Store',
'Block of Old Cheese',
'Baseball Bat'
}

has_item = {
'Main Floor': {'Gas Mask'},
'North Hall': {'Stuffed Shark'},
'Storage Room': {'Bubble Wrap'},
'South Hall': {'Knowledge of Toaster Store'},
'Food Court': {'Block of Old Cheese'},
'Clothes Store': {'Baseball Bat'}
}

inventory = {

}

def search_for_items():
if room has_item = true:
add item to inventory
print('Got item: {}'.format(item))
has_item = false
else:
print('No items here')
Ich muss also herausfinden>

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post