gods = {"greek":["Zeus", "Hades", "Poseidon"], "egypt":["Osiris", "ra", "horus"]} # Add keys / list in Dictionary "gods" def dictin(): try: addict = int(input("")) for i in range(addict): goddict = input("") if goddict == "!q": break elif goddict in gods: print('**ERROR MESSAGES**') print('ERROR: ' + "\"" + goddict + "\"" + ' is already in use') print('***') print("\n") elif goddict.isdigit(): print('ERROR for key: \"' + goddict + "\"") else: gods[goddict] = [] except ValueError: print("Keine Integer! Bitte nochmals versuchen ...") # Ask if you want to add an item in a specific list def boolrequesting(): print("Do you want to add some items in a keyword? y/n") boolini = input("") if boolini in ['y', 'Y', 'yes', 'Yes', 'YES']: crtitemlist() print("hello") # Add items in list def crtitemlist(): print("In which key do you want to add the items? ") selectdict = str(input("KEY: ")) print(selectdict) amount = int(input("Amount: ")) print(amount) for t in range(amount): cosinput = input("") print ("Add: " + cosinput) if cosinput == "!q": break gods[selectdict].append(cosinput) # List current information dictin() boolrequesting() print("###ACCEPTED###") print(gods) for i in sorted(gods): print ('gods.dict.key: ' + i) #Output #request() #note ''' cosinput = input("") tosinput = input("") gods["greek"].append(cosinput) gods["egypt"].append(tosinput) if cosinput in gods["greek"]: print("Hello " + cosinput) print("Hello " + tosinput) '''
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question