python - How can I detect if a dictionary has certain criteria? -


i'm trying implement save feature game save variety of information. save part works fine, load part not work. current dictionary:

player_data = {'x':x, 'y':y, 'world':mapsection, 'introcomplete':homeintro} 

i loading/saving this:

def save_game():     open("savegame", "wb") f:         pickle.dump(player_data, f) def load_game():     open("savegame", "rb") f:         global player_data         player_data = pickle.load(f) 

and see mapsection set as, use this:

load_game() print(player_data) if "1_1" in player_data:     print('maploaded')     game_map_1_1() else:     print('reset')     game_intro() 

but reason, skips on if statement else statement. don't know doing wrong.

i'm guessing want check player_data['world'] == '1_1' , not '1_1' in player_data. second 1 checks if have key named 1_1.

this not specific pickle.


Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -