-
-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Labels
PythonPython Interview QuestionsPython Interview QuestionsenhancementNew feature or requestNew feature or requestquestionFurther information is requestedFurther information is requested
Milestone
Description
🐍 Program 139: Create Dictionary of Lowercase and Uppercase Letters
📌 Description
Write a function that creates a dictionary with each (key, value) pair being the (lowercase, uppercase) versions of a letter, respectively.
💡 Code Example
def mapping(lst):
return {letter: letter.upper() for letter in lst}
# Examples
print(mapping(["p", "s"])) # ➞ { "p": "P", "s": "S" }
print(mapping(["a", "b", "c"])) # ➞ { "a": "A", "b": "B", "c": "C" }
print(mapping(["a", "v", "y", "z"])) # ➞ { "a": "A", "v": "V", "y": "Y", "z": "Z" }✅ Output
{'p': 'P', 's': 'S'}
{'a': 'A', 'b': 'B', 'c': 'C'}
{'a': 'A', 'v': 'V', 'y': 'Y', 'z': 'Z'}
🧠 Explanation
- The function uses a dictionary comprehension to iterate over each letter in the input list.
- For each letter, it maps the lowercase letter (key) to its uppercase version (value).
Metadata
Metadata
Assignees
Labels
PythonPython Interview QuestionsPython Interview QuestionsenhancementNew feature or requestNew feature or requestquestionFurther information is requestedFurther information is requested