Dictionaries in Python - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Homework (https://python-forum.io/forum-9.html) +--- Thread: Dictionaries in Python (/thread-16505.html) |
Dictionaries in Python - erfanakbari1 - Mar-02-2019 Hello guys , I was just trying to write some codes to run Dictionary exercises then I found myself stuck in trouble writing some parts of code . # Add two dictionary and assign it to dict3 Display the dict3 dictFirst = {'maths': '24' , 'science': '58' , 'history':'76'} dictSecond = {'sports': '16' , 'music': '83'} dictResult = {**dictFirst , **dictSecond} print(dictResult) # Clear the dictionary dict2 Display the dict2 dictSecond.clear() print(dictSecond) # Delete the dictionary dict1 ''' Get input from the user and print the score in that subject if not available print proper message. (user input can be of any case.) '''In line 11 up to 18 , I can't get any heads or tails around what am I supposed to do with it . I'm very thankful If you can help me doing this . Thanls RE: Dictionaries in Python - ichabod801 - Mar-02-2019 You get user input using the input function (answer = input('question? ')), you allow for any case by lower casing it (answer.lower()), and you access dictionary items with brackets (dictResult['maths']). |